Com 尝试在win 8.1中读取storageItem文件时出现共享目标错误

Com 尝试在win 8.1中读取storageItem文件时出现共享目标错误,com,winjs,windows-8.1,Com,Winjs,Windows 8.1,我正在尝试在win 8.1中实现共享目标应用程序契约。 示例共享目标应用程序代码有效,但当我尝试使用以下代码读取storageItem文件时: storageItems.getAt(i).openReadAsync().then(function(stream) { }); 我得到一个错误: 0x800001F-JavaScript运行时错误:对ASTA的COM调用失败 由于呼叫链起源于或通过另一个呼叫链而被阻止 阿斯塔。此调用模式容易死锁,公寓不允许使用 呼叫控制 这是另一个WinJs/W

我正在尝试在win 8.1中实现共享目标应用程序契约。 示例共享目标应用程序代码有效,但当我尝试使用以下代码读取storageItem文件时:

storageItems.getAt(i).openReadAsync().then(function(stream) {

});
我得到一个错误:

0x800001F-JavaScript运行时错误:对ASTA的COM调用失败 由于呼叫链起源于或通过另一个呼叫链而被阻止 阿斯塔。此调用模式容易死锁,公寓不允许使用 呼叫控制


这是另一个WinJs/Win8.1预览错误还是我做错了什么

我遇到了同样的问题。不幸的是,在MSFT发布的所有关于共享契约目标的示例、教程和示例代码中,没有一个真正读取共享文件

我并没有明确表示理解封面下到底发生了什么,但它涉及到在OpenReadAsync调用过程中,共享目标应用程序的UI线程和共享源程序的UI线程同时在调用堆栈上,这就是导致异常的原因

解决方案是将OpenReadAsync调用移出UI线程。很抱歉,我不知道JS的解决方法,但我在C中解决这个问题的方法是:

// BAD - This produces: "A COM call to an ASTA was blocked because the call  
// chain originated in or passed through another ASTA. This call pattern 
// is deadlock-prone and disallowed by apartment call control."
//
// IRandomAccessStreamWithContentType stream = await fileReceived.OpenReadAsync(); 

// GOOD - This moves the OpenReadAsync off of the UI thread and works fine...
//
IRandomAccessStreamWithContentType stream = await Task.Run(async () =>
{
    return await fileReceived.OpenReadAsync(); 
});

我遇到了同样的问题。不幸的是,在MSFT发布的所有关于共享契约目标的示例、教程和示例代码中,没有一个真正读取共享文件

我并没有明确表示理解封面下到底发生了什么,但它涉及到在OpenReadAsync调用过程中,共享目标应用程序的UI线程和共享源程序的UI线程同时在调用堆栈上,这就是导致异常的原因

解决方案是将OpenReadAsync调用移出UI线程。很抱歉,我不知道JS的解决方法,但我在C中解决这个问题的方法是:

// BAD - This produces: "A COM call to an ASTA was blocked because the call  
// chain originated in or passed through another ASTA. This call pattern 
// is deadlock-prone and disallowed by apartment call control."
//
// IRandomAccessStreamWithContentType stream = await fileReceived.OpenReadAsync(); 

// GOOD - This moves the OpenReadAsync off of the UI thread and works fine...
//
IRandomAccessStreamWithContentType stream = await Task.Run(async () =>
{
    return await fileReceived.OpenReadAsync(); 
});

彼此彼此!我不知道是什么问题。如果你发现了什么,请分享。尚未找到解决方案/彼此彼此!我不知道是什么问题。如果你发现了什么,请分享。尚未找到解决方案/