繁体   English   中英

无法加载文件或程序集'System.Runtime.Handles'-Xamarin UWP

[英]Could not load file or assembly 'System.Runtime.Handles' - Xamarin UWP

我们在整个代码中都使用了隔离存储,并且一直运行良好。 突然,这个错误开始出现在几个不同的项目中,这意味着我根本无法使用隔离存储。 我尝试添加System.Runtime.Handles NuGet程序包,但没有任何区别。

这是代码:

        using (var userStore = IsolatedStorageFile.GetUserStoreForApplication())
        {
        }

发生System.IO.IsolatedStorage.IsolatedStorageException
HResult = 0x80131450消息=不允许操作。 Source = StackTrace:位于System.IO.IsolatedStorage.IsolatedStorageFile.FetchOrCreateRoot()处的System.IO.IsolatedStorage.IsolatedStorageFile.CreatePathPrefixIfNeeded(字符串路径)
在System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStore()在System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()在Adapt.Presentation.XivicControls.XivicUtilities.CreateAttachmentsFolders()在C:\\ AdaptSource \\ Xivic \\ Adapt.Presentation.X Adapt \\ Presentation \\ XivicControls \\ XivicUtilities-Xamarin Forms.cs:C. \\ AdaptSource \\ Xivic \\ Adapt.Presentation.XamarinForms \\ Adapt \\ Presentation \\ XamarinForms \\ App的Adapt.Presentation.XamarinForms.App.d__31.MoveNext()的第19行.xaml.cs:第99行

内部异常1:FileNotFoundException:无法加载文件或程序集'System.Runtime.Handles,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'。 该系统找不到指定的文件。

但是,这也是一个编译时问题。 我在单独的项目中收到此编译器错误消息:

严重性代码说明项目文件行抑制状态错误无法复制文件“ C:\\ Users \\ chris.nuget \\ packages \\ runtime.any.System.Runtime.Handles \\ 4.3.0 \\ lib \\ netstandard1.3 \\ System.Runtime。 Handles.dll”,因为找不到。 TestXamarinForms.UWP C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Professional \\ MSBuild \\ 15.0 \\ Bin \\ Microsoft.Common.CurrentVersion.targets 4222

如果您在此处签出我的存储库,就可以轻松看到错误: https://ChristianFindlay@bitbucket.org/ChristianFindlay/xamarin-forms-scratch.git

无需执行任何操作即可解决此问题。 我无法解释它是如何解决的,但是我怀疑这是Appx安装的问题。 我相信该应用程序的安装已损坏,因此隔离存储也已损坏。 由于不同的原因,我在这里启动了另一个线程:

UWP App无法启动

我需要像这样通过powershell卸载应用程序的答案是因为该应用程序以某种方式安装了其他用户名:

Get-appxpackage -allusers <appname> | Remove-AppxPackage

隔离存储现在可以使用。 神奇的是,我通过相同的错误消息遇到的编译错误也已清除。 这一切仍是一个谜。

据我所知Xamarin应用程序不支持IsolatedStorage 您应该在每个平台上使用本机存储机制来存储文件/数据/设置-如此处所述https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/

对于UWP,您将需要使用System.IO.FileWindows.Storage来存储和管理文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM