gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 10:36:53 25 4
gpt4 key购买 nike

我想使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com