获取 Silverlight 程序集的运行时版本 [英] Getting runtime version of a Silverlight assembly

查看:22
本文介绍了获取 Silverlight 程序集的运行时版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在关于框中显示我的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆