小编tro*_*you的帖子

在winrt中访问文件时出现一些异常

我在winrt中访问文件时遇到一些问题

问题1:

var file = await StorageFile.GetFileFromPathAsync(filePath);
Run Code Online (Sandbox Code Playgroud)

有时,GetFileFromPathAsync将抛出"rpc服务器不可用"异常.

问题2:

MusicProperties musicProp = await file.Properties.GetMusicPropertiesAsync();
Run Code Online (Sandbox Code Playgroud)

有时它会引发异常:

Unable to cast COM object of type 'Windows.Storage.FileProperties.MusicProperties' to interface type 'Windows.Storage.FileProperties.IMusicProperties'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{BC8AAB62-66EC-419A-BC5D-CA65A4CB46DA}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
Run Code Online (Sandbox Code Playgroud)

问题3:

QueryOptions query = new QueryOptions(CommonFileQuery.OrderByMusicInfo, extensionList);
StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(query);
IReadOnlyList<IStorageFile> files …
Run Code Online (Sandbox Code Playgroud)

microsoft-metro windows-8 windows-runtime

5
推荐指数
1
解决办法
1480
查看次数