在 Windows Phone 7 上获取程序集版本 [英] Get Assembly version on windows phone 7
本文介绍了在 Windows Phone 7 上获取程序集版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 c# 应用程序中,我通常使用以下代码获取版本(向客户展示):
In my c# applications I usually get the version (to show the customer) using the following code:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
这在 Windows Phone 7 中不起作用(它会挂起模拟器,并且手机崩溃对于 MS 来说是禁忌).
This does not work in Windows Phone 7 (it hangs the emulator, and phone crashing is a no-no for MS).
那么,如何在 Windows Phone 7 设备上获取执行的版本??
So, how do I get the version of the executing on a windows phone 7 device??
[更新] 如以下评论中所述,在 wp7 应用程序中调用 GetName() 似乎是问题所在.
[Update] as noted in the comments below, calling GetName() in a wp7 app seems to be the problem.
推荐答案
试试这个:
private static string GetVersionNumber()
{
var asm = Assembly.GetExecutingAssembly();
var parts = asm.FullName.Split(',');
return parts[1].Split('=')[1];
}
这篇关于在 Windows Phone 7 上获取程序集版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文