积极答复者
使用DeviceInformation.FindAllAsync()出现System.UnauthorizedAccessException 异常

问题
-
在Windows 8.1 (9477或9471 )上开发Metro应用,当页面上使用ToggleSwitch控件,并且程序具有多语言版本(添加了资源文件的本地化),在Control Panel\Clock, Language, and Region\Language中设置primary language不是系统语言时,使用DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)会出现System.UnauthorizedAccessException 异常。
但是,Windows8.1(9431)之前版本没有上述问题,请问是什么原因?
追加Troubleshooting tips:
If you are attempting to access a file, make sure it is not ReadOnly. Make sure you have sufficient privileges to access this resource.
请问在调FindAllAsync()时访问了什么文件?
简单建一个C# Store App,问题就再现。
【MainPage.xaml】
<Page x:Class="App_Debug.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App_Debug" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <ToggleSwitch /> </Page>
【MainPage.xaml.cs】
using System; using System.Collections.Generic; using System.IO; using System.Linq; using Windows.Devices.Enumeration; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 namespace App_Debug { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } /// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { var _Devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); } } }
工程中必须添加多语言资源文件,Resources.resw可以是空文件。
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="App_Debug_TemporaryKey.pfx" />
<PRIResource Include="Strings\de\Resources.resw" />
<PRIResource Include="Strings\en\Resources.resw" />
<PRIResource Include="Strings\es\Resources.resw" />
<PRIResource Include="Strings\fr\Resources.resw" />
<PRIResource Include="Strings\it\Resources.resw" />
<PRIResource Include="Strings\ja\Resources.resw" />
<PRIResource Include="Strings\ko\Resources.resw" />
<PRIResource Include="Strings\ru\Resources.resw" />
<PRIResource Include="Strings\zh-CN\Resources.resw" />
<PRIResource Include="Strings\zh-TW\Resources.resw" />
</ItemGroup>- 已编辑 oliver29520 2013年8月21日 9:13
答案
-
Hi Oliver,
多谢反馈问题,不过不好意思我本地做不了测试(没有那么多版本可以被测试),所以我推荐你可以到Connect上去提出这个问题。
可以在Visual Studio and .NET Framework这个子模块中提出你的疑问,他们会帮你测试并且告诉你这是否是一个bug,同时建议同英文提出这个问题,貌似他们暂时没有中文的服务项目。
在此再次感谢对论坛的支持。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已编辑 Jamles HezModerator 2013年8月22日 3:05 txt
- 已标记为答案 oliver29520 2013年8月23日 2:51
全部回复
-
Hi Oliver,
多谢反馈问题,不过不好意思我本地做不了测试(没有那么多版本可以被测试),所以我推荐你可以到Connect上去提出这个问题。
可以在Visual Studio and .NET Framework这个子模块中提出你的疑问,他们会帮你测试并且告诉你这是否是一个bug,同时建议同英文提出这个问题,貌似他们暂时没有中文的服务项目。
在此再次感谢对论坛的支持。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- 已编辑 Jamles HezModerator 2013年8月22日 3:05 txt
- 已标记为答案 oliver29520 2013年8月23日 2:51
-
Hi Oliver,
8.1的版本预计在10月左右发布,不过时间仍属于待定,美国方面已经在做最后的测试和修复工作,如果你提出的问题的确是一个bug,很大可能性会在8.1的下一个版本中修复,具体的情况我也不能给出一个确定的答复。
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.