简体   繁体   English

支持WP8,同时具有WP8.1的附加功能

[英]Supporting WP8 while having extra features for WP8.1

I developed an app for Windows Phone 8 previously and now I'd like to add Windows.Security.Cryptography to my app, which is a new feature shipped with Windows Phone 8.1. 我以前为Windows Phone 8开发了一个应用程序,现在我想将Windows.Security.Cryptography添加到我的应用程序中,这是Windows Phone 8.1附带的一项新功能。

Problem appears after I finish developing on WP8.1. 我在WP8.1上完成开发后出现问题。 I can successfully build the app on WP8.1 with the cryptography features working. 我可以使用加密功能在WP8.1上成功构建该应用程序。 But the app never works on WP8 platforms any more (which is expected). 但是该应用程序再也无法在WP8平台上运行了(这是预期的)。

Is there a way that I can build one app that works on both WP8 and WP8.1, while on WP8.1 I can have extra support for new features? 有没有一种方法可以构建可以同时在WP8和WP8.1上使用的应用程序,而在WP8.1上可以对新功能提供额外的支持?

From what I understand, Windows.Security.Cryptography is available in Windows Phone Silverlight 8.1 apps. 据我了解,Windows Phone Silverlight 8.1应用程序中提供了Windows.Security.Cryptography This means that you could use it in a WP 8.0 app through reflection. 这意味着您可以通过反射在WP 8.0应用程序中使用它。 Something like this: 像这样:

// Get the type object of the class that you want (I picked a random one, and it worked)
var engineType = Type.GetType("Windows.Security.Cryptography.Core.CryptographicEngine, Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime");

Once you have the type, you can instantiate it, invoke its methods and so on. 一旦有了类型,就可以实例化它,调用它的方法等等。 You may try to instantiate the object and put it in a dynamic variable, so that you wouldn't need to manually reflect every method/property that you need. 您可以尝试实例化该对象并将其放在dynamic变量中,这样就无需手动反映所需的每个方法/属性。 I haven't tested it with dynamic though, so it's just an idea. 我还没有用dynamic测试过它,所以这只是一个主意。 If you try it, please write a comment if it works or not. 如果您尝试使用它,请写一条评论,不管它是否有效。

So, you'll have just one WP 8.0 app and if it's deployed on a WP8.1 device, it will have access to some new features. 因此,您只有一个WP 8.0应用程序,如果将其部署在WP8.1设备上,它将可以使用一些新功能。

Unfortunately there is no way you can make that work. 不幸的是,您无法进行这项工作。 WP 8.1 can run 8.0 apps but it doesn't work the other way around. WP 8.1可以运行8.0应用程序,但不能正常工作。 What you should do is submit the 8.1 package with the new features but also keep the 8.0 XAP (don't delete it) so people using Windows Phone 8.0 can still download your app, albeit without the extra 8.1 features. 您应该做的是提交具有新功能的8.1程序包,同时保留8.0 XAP(不要删除它),以便使用Windows Phone 8.0的人仍然可以下载您的应用程序,尽管没有额外的8.1功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM