获取Silverlight程序集的运行时版本 [英] Getting runtime version of a Silverlight assembly
问题描述
我想在About框中显示我的Silverlight 3应用程序的版本号,但是当我使用传统的.Net调用时:
I want to show my Silverlight 3 application's version number in the about box, but when I use a traditional .Net call like:
Assembly.GetExecutingAssembly().GetName().Version;
我在GetName()调用中收到MethodAccessException。我应该如何获取程序集的版本号?
I get a MethodAccessException on the GetName() call. How am I supposed to get the version number of my assembly?
推荐答案
private static Version ParseVersionNumber(Assembly assembly)
{
AssemblyName assemblyName = new AssemblyName(assembly.FullName);
return assemblyName.Version;
}
或此:
Assembly assembly = Assembly.GetExecutingAssembly();
String version = assembly.FullName.Split(',')[1];
String fullversion = version.Split('=')[1];
来自: http://betaforums.silverlight.net/forums/p/128861/288595.aspx
关于它的帖子:
http://forums.silverlight.net/forums/p/93400/214554.aspx
您可以查看我发布的js文件此处:检测程序集所需的Silverlight版本
You can look at the js file I posted here: Detect Silverlight version required by an assembly
您的错误是预期的。由于它是安全关键的,上面是一些解决方法。
Your error is expected.as it is secutiry critical, above are some work arounds.
这篇关于获取Silverlight程序集的运行时版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!