在 Metro 风格应用程序中使用旧程序集 [英] using legacy assemblies in metro style app

查看:26
本文介绍了在 Metro 风格应用程序中使用旧程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以在用 c# 编写的 Metro 风格应用程序中访问部分 .net api 和所有 winrt api.但是针对 .net 2.0 或 3.5 等的其他第三方组件呢?我们能否将它们作为参考添加到 Metro 风格的应用项目中?

I understand that we can access part of the .net apis and all the winrt apis in a metro style app written in c#. But what about other third-party components that target .net 2.0 or 3.5, etc. will we be able to add them as references in a metro style app project?

推荐答案

是的,有时您可以从 Metro 应用程序引用第三方 .NET 程序集.它们应与您的应用程序部署在同一文件夹中,并且仅使用受支持的 API.

Yes, sometimes you can reference third-party .NET assemblies from Metro applications. They should be deployed in the same folder as your app and only use supported APIs.

我创建了一个带有一个类的 .NET 库,并从 Metro 应用程序中使用它.收到以下警告:无法引用项目EmptyLib".但是应用程序已经构建,我能够对其进行调试并在调试器中探索我的类的实例.

I created a .NET library with one class and used it from metro app. Got the following warning: The project 'EmptyLib' cannot be referenced. But the app has been built and I was able to debug it and explore the instance of my class in debugger.

然后我尝试通过 Windows 应用程序认证.它失败了(请参阅下面的详细信息).

Then I tried to pass Windows App Certification. It failed (see details below).

为应用认证开启编译器优化后通过.

After switching on compiler optimization for app certification passed.

第一次失败的原因是库使用了不支持的 API.详情:

The reason that it failed the first time was that library used not supported APIs. Details:

错误:此应用程序未通过支持的 API 检查.

Error: This application failed the supported API check.

  • 此应用程序类型不支持 MSCORLIB 中的 API System.Runtime.CompilerServices.CompilationRelaxationsAttribute,PUBLICKEYTOKEN=B77A5C561934E089.EmptyLib.dll 调用此 API.

  • API System.Runtime.CompilerServices.CompilationRelaxationsAttribute in MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089 is not supported for this application type. EmptyLib.dll calls this API.

此应用程序类型不支持 MSCORLIB 中的 API System.Runtime.CompilerServices.CompilationRelaxationsAttribute.#ctor(System.Int32),PUBLICKEYTOKEN=B77A5C561934E089.EmptyLib.dll 调用此 API.

API System.Runtime.CompilerServices.CompilationRelaxationsAttribute.#ctor(System.Int32) in MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089 is not supported for this application type. EmptyLib.dll calls this API.

如果不修复会产生影响:应用程序正在使用 Windows SDK for Metro 风格应用程序中没有的一个或多个 API.使用不受支持的 API 违反了 Windows 应用商店政策,可能会对用户体验产生负面影响,并有可能阻碍整体系统稳定性.

Impact if not fixed: The application is using one or more APIs that are not in the Windows SDK for Metro style Apps. Use of unsupported APIs violates the Windows Store policy and can have negative impact on the user experience and has the potential to hinder overall system stability.

如何修复:查看上面的错误消息 2 以了解需要修复的确切 API.请参阅适用于 Metro 风格应用程序的 Windows SDK,了解支持使用的 API 列表.

How to fix: Look at the error messages above2 for the exact API that needs to be fixed. Refer to the Windows SDK for Metro style Apps for the supported list of APIs to use.

这篇关于在 Metro 风格应用程序中使用旧程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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