【问题标题】:Windows 8 - WriteTextAsync exception "Cannot evaluate expression because a native frame is on top of the call stack."Windows 8 - WriteTextAsync 异常“无法评估表达式,因为本机框架位于调用堆栈的顶部。”
【发布时间】:2014-01-06 21:56:03
【问题描述】:

我想使用 StorageFile 来实现阅读和写作,如下所示

http://msdn.microsoft.com/en-us/library/windows/apps/hh758325.aspx#writing_to_a_file

public async void Save()
{
    StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
    StorageFile sampleFile = await storageFolder.CreateFileAsync(PlayerPrefs.GetString("WorldName") +"_"+filename);
    await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow");
}

但是“await”行给出了异常

+    $exception {Cannot evaluate expression because a native frame is on top of the call stack.} System.Exception {System.UnauthorizedAccessException}

如果这有什么不同的话,我将 Unity 与 Windows 8 应用商店一起使用。

有人知道这是什么问题吗?

【问题讨论】:

    标签: c# windows windows-8 microsoft-metro unity3d


    【解决方案1】:
    Cannot evaluate expression because a native frame is on top of the call stack
    

    这只告诉我们线程正在执行unmanaged code,因此它无法计算表达式。

    真正的错误是System.UnauthorizedAccessException

    所以打开您的 Package.appxmanifest,转到 Capabilities 选项卡并检查 Document Library Access

    【讨论】:

      【解决方案2】:

      只需创建测试证书并在解决方案属性的“签名”选项中选中“签署 ClickOnce 清单”,并在解决方案资源管理器中右键单击解决方案名称。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-05-08
        • 2012-07-11
        • 2012-10-22
        相关资源
        最近更新 更多