c# - Windows 8 - WriteTextAsync 异常 "Cannot evaluate expression because a native frame is on top of the call stack."

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

我想使用 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 应用商店一起使用。

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

最佳答案

Cannot evaluate expression because a native frame is on top of the call stack

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

真正的错误是 System.UnauthorizedAccessException

因此,打开您的Package.appxmanifest,转到Capabilities 选项卡并选中Document Library Access

关于c# - Windows 8 - WriteTextAsync 异常 "Cannot evaluate expression because a native frame is on top of the call stack.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20960008/

相关文章:

具有不同运行时的 C# While 循环

php - 将文件从尼康 D60 数码相机复制到 WAMP 服务器的脚本?

c# - VS2010 抛出 "Could not copy the file "obj\x86\Debug\[file].exe“因为找不到。”

xaml - 检查 Windows 8 应用商店应用程序/VS2012 中的 XAML

c# - 如何禁用 WinRT 的 HttpWebRequest 中的 “Expect: 100 continue” header

c# - 使用值从哈希表中查找

c# - MVVM Light 绑定(bind)到 Observable 集合

c# - 正则表达式从字符串中删除所有空格、句点和其他非单词字符

python - 如何在 Kivy 中编写窗口移动事件的处理程序?

windows - 有没有win的浏览器可以用来测试html5 localstorage的?