windows - 等效于 system.Reflection.Assembly.GetExecutingAssembly().FullName

标签 windows silverlight uwp

目前,我正在使用 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 中似乎并不都存在。我唯一能找到的是:

  1. System.Reflection.Assembly.equals
  2. System.Reflection.Assembly.load
  3. 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文件夹下。

enter image description here

关于windows - 等效于 system.Reflection.Assembly.GetExecutingAssembly().FullName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33611919/

相关文章:

c# - Windows 应用商店应用程序中的 System.Environment 替换?

c++ - 想要开发我自己的基本上会显示 HTML、Javascript 和 Flash 的小型 C++ 浏览器,从哪里开始?

python - 与 Windows 上的 Spyder 相比,为什么 Ubuntu 上的 Spyder 是 "//"而不是 "\\"?

即使授予 "Everyone"访问权限,ASP.NET 应用程序也无法访问网络共享

c# - 检测Silverlight是否从c#安装

javascript - 为什么这在 Firefox 和 Chrome 中失败?

windows - startxwin - cygwin 上的 startx

silverlight - RIA 服务和 nHibernate 插入新问题

c# - 警告 : MapServiceToken not specified

c# - UWP AppServiceConnection 没有获得值(value)