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

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

问题描述

我开发了一个使用 EF7 和 SQLite 的简单且小型的通用 Windows 应用程序.它在选项编译与.NET本机刀具链"中,顺利进行编译并运行,并不是未选中.

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 能够在 3 月的某个时候更新 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 Native 工具链编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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