求助,SL获取程序AssemblyInfo.cs文件中版本信息失败
我用如下方法获取程序的版本信息
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
会报如下的错误
访问安全关键方法“System.Reflection.Assembly.GetName()”的尝试失败。
请大师指教?
[解决办法]
试着使用这个代码:
Assembly SampleAssembly;// Instantiate a target object.Int32 Integer1 = new Int32();Type Type1;// Set the Type instance to the target class type.Type1 = Integer1.GetType();// Instantiate an Assembly class to the assembly housing the Integer type. SampleAssembly = Assembly.GetAssembly(Integer1.GetType());// Display the name of the assembly currently executingConsole.WriteLine("GetExecutingAssembly=" + Assembly.GetExecutingAssembly().FullName);