博文

目前显示的是 八月, 2018的博文

Assembly in C#

1. using System.Reflection.Assembly System.Reflection.AssemblyName name = System.Reflection.Assembly.GetExecutingAssembly().GetName(); //name is {AssemblyNameInProperties, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null} byte[]  key =  name.GetPublicKey(); 2. reflection Assembly assem = typeof (ExampleClass).Assembly; // Create an object from the assembly, passing in the correct number // and type of arguments for the constructor. Object o = assem.CreateInstance( "Example" , false , BindingFlags.ExactBinding, null , new Object[] { 2 }, null , null ); // Make a late-bound call to an instance method of the object. MethodInfo m = assem.GetType( "Example" ).GetMethod( "SampleMethod" ); Object ret = m.Invoke(o, new Object[] { 42 }); Console.WriteLine( "SampleMethod returned {0}." , ret); reference: docs.microsoft.com/en-us/dotnet/api/system.re