Assembly.GetExecutingAssembly不在PCL存在

编程入门 行业动态 更新时间:2024-10-19 16:34:07
本文介绍了Assembly.GetExecutingAssembly不在PCL存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我成立了一个PCL在VB,VS2012,并将其设置为档案78(WinRT的,WinPhone8,.NET 4.5)。我没有 GetExecutingAssembly 在组装可用。据this,它应该是提供给PCLS。唯一可用的方法是的Assembly.Load()。

I set up a PCL in VB, VS2012 and set it for Profile 78 (WinRT, WinPhone8, .NET 4.5). I don't have GetExecutingAssembly available on Assembly. According to this, it should be available to PCLs. The only method available is Assembly.Load().

有没有人,我应该怎样做呢?例如。这是真的,是我的环境搞砸了,有另一种方式来访问除进口的System.Reflection GetExecutingAssembly 其他?任何其他的想法?

Does anyone what I should do with this? E.g. is this true, is my environment screwed up, is there another way to access GetExecutingAssembly other than Imports System.Reflection? Any other ideas?

推荐答案

在一般情况下,你应该使用类似的typeof(MyType的).GetTypeInfo()。大会而不是 Assembly.GetExecutingAssembly()。 GetExecutingAssembly已基本检查调用堆栈要弄清楚什么方法调用,然后查找对应的汇编。这将打破,如果方法是不断跨越内联汇编的界限,这就是为什么GetExecutingAssembly方法不是在新的反射面面积的配置文件78(以及.NET为Windows应用商店的应用程序)使用。

In general, you should use something like typeof(MyType).GetTypeInfo().Assembly instead of Assembly.GetExecutingAssembly(). GetExecutingAssembly has to basically examine the call stack to figure out what method is calling it and then look up the corresponding assembly. This could break if methods are ever inlined across assembly boundaries, which is why the GetExecutingAssembly method isn't in the "new" reflection surface area which Profile 78 (as well as .NET for Windows Store apps) uses.

更多推荐

Assembly.GetExecutingAssembly不在PCL存在

本文发布于:2023-11-13 14:43:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584610.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Assembly   GetExecutingAssembly   PCL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!