UWP-.NET本机工具链编译错误 [英] UWP - .NET Native tool chain compilation error

查看:106
本文介绍了UWP-.NET本机工具链编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用EF7和SQLite的小型通用Windows应用程序。如果未选中选项使用.NET Native工具链编译 ,它将编译并平稳运行。

I've developed a simple and small Universal Windows App that uses EF7 and SQLite. It compiles and runs smoothly when the option "Compile with .NET Native tool chain" is unchecked.

如果我选中选项 使用.NET Native工具链编译 ,出现以下编译错误:

If I check the option "Compile with .NET Native tool chain", I get the following compilation error:


错误类型'System.MarshalByRefObject'未包括在编译中,但在类型'Microsoft.Data.Entity.Design.OperationExecutor'中被引用。

Error Type 'System.MarshalByRefObject' was not included in compilation, but was referenced in type 'Microsoft.Data.Entity.Design.OperationExecutor'. There may have been a missing assembly.

在此之后,还有很多其他错误,但是我相信解决这个错误也将

After this there's a lot of other errors, but I believe that solving this one will also take care of the rest.

有人知道如何解决这个问题吗?

Does anyone know how to solve this?

推荐答案

我想发生的事情是您使用的库没有针对UWP可用的.NET外围区域。 UWP的外围区域是称为.NET Core的一组API,您可以在此处查看源代码: http:/ /www.github.com/dotnet/corefx 。很可能您将需要较新版本的EF ...尽管我知道他们在我们的提前编译策略上还有其他问题(请参阅: https://github.com/aspnet/EntityFramework/issues/3603 )。我们将继续与他们合作,以解决问题,并希望EF可以在三月的某个时候在Update 2上占有一席之地。

I presume what has happened is that you're using a library that isn't targeting the .NET surface area available to UWP. The surface area for UWP is the set of APIs called .NET Core, you can see the source here: http://www.github.com/dotnet/corefx. Most likely you'll need a newer version of EF... although I know they've had some other issues with our ahead of time compilation strategy (see: https://github.com/aspnet/EntityFramework/issues/3603). We're continuing to work with them to get it sorted out and are hopeful that EF will be in a great place by Update 2 sometime in March.

在.NET Native中看到此信息是因为编译器正在编译时遍历整个应用程序,以便为它认为要调用的所有内容生成本机代码。碰巧注意到该类型不可用,并且正确地出错了。我想您实际上并没有在应用程序中调用此代码路径,因为它会在CoreCLR上产生类似的错误...它只会在运行时发生,而不是在编译时发生。

The reason you only see this with .NET Native is because the compiler is walking your entire application at compile time in order to generate native code for everything that it thinks you're going to call. It happens to notice that this type is unavailable and correctly errors out. I presume you don't actually call this code path in your application because it would produce a similar error on CoreCLR... it would just happen at runtime and not compile time.

如果您实际上不需要此类型(并且您所需的所有其他内容也不需要此类型等),则有可能从应用程序中删除此指令将使摇树器在您的应用程序中消除此类型事情出错了:

If you don't actually need this type (and everything else you need also doesn't need this type etc etc), it's possible that removing this directive from your application will allow the tree shaker to eliminate this type from your application before things go awry:

    <Assembly Name="*Application*" Dynamic="Required All" />

此指令导致应用程序中的所有类型以及您引用的非框架库都被植根,因此无法动摇。默认情况下使用此指令可以使我们的分析更加容易,并使大多数人不必对我们的分析引擎有任何了解。删除它可以帮助您避免此问题。

This directive causes all of the types in your application and the non framework libraries you reference to be rooted and thus unable to be shaken away. Having this directive by default makes our analysis easier and keeps most folks from having to know too anything about our analysis engine. It's possible that removing this can help you avoid the issue.

让我知道是否可行,或者您还有其他问题。我们一直很乐意在dotnetnative@microsoft.com上获得反馈并提供一些支持。

Let me know if that works out or if you have any other questions. We always love to get feedback and provide some support at dotnetnative@microsoft.com.

这篇关于UWP-.NET本机工具链编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆