目前,我正在使用 UWP 平台将 Windows Phone Silverlight 应用程序移植到 Windows Mobile。
在我的旧代码中,我使用一个函数以下列方式获取 ExecutingAssemblyName:
public static string ExecutingAssemblyName {
get {
string name = System.Reflection.Assembly.GetExecutingAssembly().FullName;
return name.Substring(0, name.IndexOf(','));
}
}
现在我想在 Windows Mobile 中获得相同的结果,但以下 link 中描述的功能在 Windows Mobile 中似乎并不都存在。我唯一能找到的是:
- System.Reflection.Assembly.equals
- System.Reflection.Assembly.load
- System.Reflection.Assembly.ReferenceEquals
现在有人知道如何获得相同的结果吗?或者我应该开始重写很多代码。
谢谢你了
最佳答案
要获取程序集的全名,您可以使用以下代码(如 Romasz 所述)。
this.GetType().GetTypeInfo().Assembly.FullName
在 UWP 中,所有提交到商店的应用程序都将符合 .NET Native。
The .NET Native runtime doesn't include a JIT compiler. As a result, all necessary native code must be generated in advance. A set of heuristics is used to determine what code should be generated, but these heuristics cannot cover all possible metaprogramming scenarios.
更多信息请引用文章Reflection and .NET Native .
对于你的情况,我建议你使用资源文件(Resources.resw)来管理文本资源,并将文件资源(如图像,图标)放在Assets文件夹下。
关于windows - 等效于 system.Reflection.Assembly.GetExecutingAssembly().FullName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33611919/