C# 无法加载文件或程序集“System.Runtime.Handles”-Xamarin UWP
我们在代码中使用隔离存储,它一直工作良好。突然,这个错误开始出现在一些不同的项目中,这意味着我根本不能使用独立存储。我尝试添加System.Runtime.Handles NuGet包,但没有效果 代码如下:C# 无法加载文件或程序集“System.Runtime.Handles”-Xamarin UWP,c#,.net,xamarin,uwp,isolatedstorage,C#,.net,Xamarin,Uwp,Isolatedstorage,我们在代码中使用隔离存储,它一直工作良好。突然,这个错误开始出现在一些不同的项目中,这意味着我根本不能使用独立存储。我尝试添加System.Runtime.Handles NuGet包,但没有效果 代码如下: using (var userStore = IsolatedStorageFile.GetUserStoreForApplication()) { } 发生System.IO.IsolatedStorage.IsolatedStorage
using (var userStore = IsolatedStorageFile.GetUserStoreForApplication())
{
}
发生System.IO.IsolatedStorage.IsolatedStorage异常
HResult=0x80131450消息=不允许操作。Source=StackTrace:at
System.IO.IsolatedStorage.IsolatedStorageFile.CreatePathPrefixFneedString
路径在
System.IO.IsolatedStorage.IsolatedStorageFile.FetchOrCreateRoot
位于System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStore处
System.IO.IsolatedStorage.IsolatedStorage.GetUserStoreForApplication
在
Adapt.Presentation.XivicControls.XivicUtilities.CreateAttachmentsFolders
在里面
C:\adaptesource\Xivic\Adapt.Presentation.XamarinForms\Adapt\Presentation\XivicControls\XivicUtilities
-Xamarin Forms.cs:Adapt.Presentation.Xamarin Forms.App.d_u31.MoveNext中的第19行
在里面
C:\adaptesource\Xivic\Adapt.Presentation.XamarinForms\Adapt\Presentation\XamarinForms\App.xaml.cs:line
九十九
内部异常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
如果您在此处查看我的回购协议,您很容易看到错误:
据我所知,Xamarin应用程序不支持IsolatedStorage。您应该在每个平台上使用本机存储机制来存储文件/数据/设置,如下所述
对于UWP,您需要使用System.IO.File或Windows.Storage来存储和管理文件。此问题已解决,无需执行任何操作。我无法解释它是如何解决的,但我怀疑这是Appx安装的问题。我相信应用程序的安装不知何故被破坏了,因此隔离存储也被破坏了。我在这里开始另一个线程是出于不同的原因: 我需要像这样通过powershell卸载应用程序,因为该应用程序以不同的用户名安装:
Get-appxpackage -allusers <appname> | Remove-AppxPackage
隔离存储现在可以工作了。神奇的是,我在同一条错误消息中遇到的编译错误也被清除了。这仍然有点神秘。我们已经使用隔离存储很长时间了。如果他们已经停止支持它,我想看一篇关于它的文章。除此之外,这个错误在编译时出现在一个单独的项目中,它甚至不使用IsolatedStorage