0
我试图在Silverlight应用程序中获取程序集文件版本。由于Silverlight不具备FileVersionInfo类,this似乎是推荐的方式来获取信息:获取用于Silverlight的汇编文件版本返回星号
var executingAssembly = Assembly.GetExecutingAssembly();
var customAttributes = executingAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
if (customAttributes != null)
{
var assemblyFileVersionAttribute = customAttributes[0] as AssemblyFileVersionAttribute;
return assemblyFileVersionAttribute.Version;
}
然而,上面的代码返回1.2.0.*
。这确实是AssemblyInfo.cs文件中的内容,但我需要实际的文件版本(不带星号)而不是1.2.0.*
。我怎样才能做到这一点?
你的意思是你想'1.2.0','1.2.0.0'还是'1.2.0.X',其中“X”是从0到9的_actual_版本号数字? –
@ChrisSinclair我在寻找1.2.0.X,其中“X”是从0到9的实际版本号数字。 –
这有帮助吗? http://stackoverflow.com/questions/2297273/getting-runtime-version-of-a-silverlight-assembly –