[UWP]无法使用'WindowsRuntimeAccess ='全部'''设置为存储在UWP C#应用程序的Package.appxmanifest中的'uap:ApplicationContentRules'中的'uap:Rule'。 [英] [UWP]Not able to submit to store with 'WindowsRuntimeAccess="all"' set as a 'uap:Rule' in one of 'uap:ApplicationContentRules' in Package.appxmanifest of a UWP C# Application.

查看:111
本文介绍了[UWP]无法使用'WindowsRuntimeAccess ='全部'''设置为存储在UWP C#应用程序的Package.appxmanifest中的'uap:ApplicationContentRules'中的'uap:Rule'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows 10开发一个UWP C#应用程序,我遇到了一个需要使用JavaScript从WebView调用UWP WinRT API的场景。我知道WinJS项目是可行的,但是我需要在C#UWP应用程序中完成。



做了一些研究后我才知道做同样的解决方法。通过将下面的代码片段添加到我的Applicaiton的Package.appxmanifest文件中,我可以在JavaScript中使用UWP API。

< uap:ApplicationContentUriRules> 
< uap:Rule Match =" ms-appx-web:///"类型="包括" WindowsRuntimeAccess = QUOT;所有" />
< / uap:ApplicationContentUriRules>


但问题是,我什么时候提交上面的Applicaiton提到更改存储,认证过程失败,出现以下错误。


在启用以下任何功能时,应用程序不能包含带有'all'或'allowForWebOnly'的WindowsRuntimeAccess的ApplicationContentUriRule:enterpriseAuthentication,
sharedUserCertificates,musicLibrary,picturesLibrary,videosLibrary,removableStorage,documentLibrary,internetClientServer,privateNetworkClientServer。



我需要上面提到的功能以及WinJS功能。



这是甚至可能?如果是的话,有人可以通过一些有用的工作帮助我解决这个问题吗?

解决方案


Hi
Nanda Velugoti



No,因为在错误消息中清楚地提到,你不能这样做。



如果您需要在HTML页面中调用uwp API,则comman解决方法是使用

WebView.ScriptNotify事件
。这可以用来与后面的代码进行交互。你也可以使用

InvokeScriptAsync方法
与webview内容进行交互背后的代码。



你可以从这里的链接获得更多信息:

https:// docs .microsoft.com / zh-CN / uwp / api / windows.ui.xaml.controls.webview#remarks









最好的问候,



罗伊


I am developing a UWP C# application for windows 10 and I came across a scenario where I need to invoke UWP WinRT APIs from WebView using JavaScript. I know it is possible with WinJS project but I need to do it in C# UWP Application.

After doing some research I came to know about a workaround for doing the same. By adding the below snippet to my Applicaiton's Package.appxmanifest file I am able to use UWP APIs inside JavaScript.

<uap:ApplicationContentUriRules>
      <uap:Rule Match="ms-appx-web:///" Type="include" WindowsRuntimeAccess="all" />
</uap:ApplicationContentUriRules>

But the problem now is, when ever I submit the Applicaiton with above mentioned change to store, certification process is failing with below mentioned error.

The Application cannot include an ApplicationContentUriRule with 'all' or 'allowForWebOnly' WindowsRuntimeAccess while any of the following capabilities are enabled: enterpriseAuthentication, sharedUserCertificates, musicLibrary, picturesLibrary, videosLibrary, removableStorage, documentLibrary, internetClientServer, privateNetworkClientServer.

I need the above mentioned capabilities along with the WinJS functionality.

Is this even possible? If yes, Can anyone please help me resolve this issue with some useful work around?

解决方案

Hi Nanda Velugoti,

No, as it is mentioned clearly in the error message, you could not do that.

If you need to call uwp APIs in a HTML page, a comman workaround is that using WebView.ScriptNotify Event. This could be used to interacting with code behind. You could also use use the InvokeScriptAsync method to interacting with webview content in the code behind.

You could get more information from the link here: https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview#remarks

Best regards,

Roy


这篇关于[UWP]无法使用'WindowsRuntimeAccess ='全部'''设置为存储在UWP C#应用程序的Package.appxmanifest中的'uap:ApplicationContentRules'中的'uap:Rule'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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