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



在我们的UWP应用程序中,当在激活.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工具链一起工作。

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

谢谢你的帮助,Peter

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

  • https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/8280606-windows-10-uwp-should-support-reflection-emit-for
  • https://github.com/dotnet/corefx/issues/30127
  • https://github.com/castleproject/Core/issues/374

System.Reflection.EmitNuGet包被暂时摘牌后,我们(Castle(考虑了DynamicProxy是否应该直接以.NET Framework和.NET Core为目标,而从不以.NET Standard为目标,但.NET团队最近正式将emit API添加到.NET Standard中,之前它意外地出现在.NET Standard API中。

最新更新