Assembly.GetExecutingAssembly doesn't exist in PCL

后端 未结 2 1769
南方客
南方客 2021-01-17 09:43

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. Acco

2条回答
  •  无人共我
    2021-01-17 10:43

    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.

提交回复
热议问题