具有Castle.Core的UWP:使用.NET本机工具链错误进行编译

时间:2018-11-21 12:46:36

标签: uwp castle-dynamicproxy .net-native

在我们的UWP App中,当激活.NET Native工具链构建应用程序时,出现以下错误:

Exception thrown: 'System.Exception' in Castle.Core.dll
An exception of type 'System.Exception' occurred in Castle.Core.dll but was not handled in user code
Method 'TypeBuilder.AddInterfaceImplementation(Type)' was not included in compilation, but was referenced in ClassEmitter..ctor(ModuleScope, string, Type, IEnumerable<Type>, TypeAttributes, bool). There may have been a missing assembly.

我们的Default.rd.xml看起来像这样:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <!--
      An Assembly element with Name="*Application*" applies to all assemblies in
      the application package. The asterisks are not wildcards.
    -->
    <Assembly Name="*Application*" Dynamic="Required All" />
  </Application>
</Directives>

我不知道要添加到Default.rd.xml中才能使我的应用程序在激活.NET Native工具链的情况下工作。

我们正在使用Castle.Core在UWP应用中的Autofac IOC中进行方法拦截。

感谢您的帮助, 彼得

1 个答案:

答案 0 :(得分:4)

UWP不支持System.Reflection.Emit。它有时可能在调试中起作用,但在.NET Native编译版本中不起作用:

System.Reflection.Emit NuGet软件包被除名之后(临时),我们(城堡)考虑了DynamicProxy是否应直接针对.NET Framework和.NET Core,而不是针对.NET Standard,但是.NET团队最近正式将Emit API添加到.NET Standard,以前是偶然将其添加到.NET Standard API中。

相关问题