Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

c# - using legacy assemblies in metro style app

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.

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

After switching on compiler optimization for app certification passed.


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

Error: This application failed the supported API check.

  • API System.Runtime.CompilerServices.CompilationRelaxationsAttribute in MSCORLIB, PUBLICKEYTOKEN=B77A5C561934E089 is not supported for this application type. EmptyLib.dll calls this 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.

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...