Csharp/C Sharp by API/System.Reflection/AssemblyName
Содержание
AssemblyName.CultureInfo
using System;
using System.Reflection;
using System.Globalization;
class MainClass
{
public static void Main()
{
string name1 = "System.Data, Version=2.0.0.0," +"Culture=neutral, PublicKeyToken=b77a5c561934e089";
Assembly a1 = Assembly.Load(name1);
AssemblyName name2 = new AssemblyName();
name2.Name = "System.Xml";
name2.Version = new Version(2, 0, 0, 0);
name2.CultureInfo = new CultureInfo(""); //Neutral culture.
name2.SetPublicKeyToken(new byte[] {0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89});
Assembly a2 = Assembly.Load(name2);
Assembly a3 = Assembly.Load("SomeAssembly");
Assembly a4 = Assembly.LoadFrom(@"c:\shared\MySharedAssembly.dll");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{
Console.WriteLine(a.GetName());
}
}
}
AssemblyName.Name
using System;
using System.Reflection;
using System.Globalization;
class MainClass
{
public static void Main()
{
string name1 = "System.Data, Version=2.0.0.0," +"Culture=neutral, PublicKeyToken=b77a5c561934e089";
Assembly a1 = Assembly.Load(name1);
AssemblyName name2 = new AssemblyName();
name2.Name = "System.Xml";
name2.Version = new Version(2, 0, 0, 0);
name2.CultureInfo = new CultureInfo(""); //Neutral culture.
name2.SetPublicKeyToken(new byte[] {0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89});
Assembly a2 = Assembly.Load(name2);
Assembly a3 = Assembly.Load("SomeAssembly");
Assembly a4 = Assembly.LoadFrom(@"c:\shared\MySharedAssembly.dll");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{
Console.WriteLine(a.GetName());
}
}
}
AssemblyName.SetPublicKeyToken
using System;
using System.Reflection;
using System.Globalization;
class MainClass
{
public static void Main()
{
string name1 = "System.Data, Version=2.0.0.0," +"Culture=neutral, PublicKeyToken=b77a5c561934e089";
Assembly a1 = Assembly.Load(name1);
AssemblyName name2 = new AssemblyName();
name2.Name = "System.Xml";
name2.Version = new Version(2, 0, 0, 0);
name2.CultureInfo = new CultureInfo(""); //Neutral culture.
name2.SetPublicKeyToken(new byte[] {0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89});
Assembly a2 = Assembly.Load(name2);
Assembly a3 = Assembly.Load("SomeAssembly");
Assembly a4 = Assembly.LoadFrom(@"c:\shared\MySharedAssembly.dll");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{
Console.WriteLine(a.GetName());
}
}
}
AssemblyName.Version
using System;
using System.Reflection;
using System.Globalization;
class MainClass
{
public static void Main()
{
string name1 = "System.Data, Version=2.0.0.0," +"Culture=neutral, PublicKeyToken=b77a5c561934e089";
Assembly a1 = Assembly.Load(name1);
AssemblyName name2 = new AssemblyName();
name2.Name = "System.Xml";
name2.Version = new Version(2, 0, 0, 0);
name2.CultureInfo = new CultureInfo(""); //Neutral culture.
name2.SetPublicKeyToken(new byte[] {0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89});
Assembly a2 = Assembly.Load(name2);
Assembly a3 = Assembly.Load("SomeAssembly");
Assembly a4 = Assembly.LoadFrom(@"c:\shared\MySharedAssembly.dll");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{
Console.WriteLine(a.GetName());
}
}
}
new AssemblyName()
using System;
using System.Reflection;
class MainClass
{
public static void Main(string[] args)
{
AssemblyName assembly1 = new AssemblyName("com.microsoft.crypto, " +
"Culture=en, PublicKeyToken=a5d015c7d5a0b012, Version=1.0.0.0");
}
}