无法加载文件或程序集 'System.Private.CoreLib...'
Could not load file or assembly 'System.Private.CoreLib...'
我有一个针对 .net 标准 1.4 的 Xamarin.Forms 应用程序。在最低版本为 14393(目标为 16299)的 UWP 应用程序上,我从 Microsoft Store 收到以下异常(尽管在我的计算机上它甚至从 appxbundle
文件运行良好):
注意要点:
- 错误发生在
OnLaunched
中的 Xamarin.Forms.Forms.Init(e);
。
- 错误本身是
Could not load file or assembly 'System.Private.CoreLib...'
。
System.IO.FileNotFoundException: Could not load file or assembly
'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified. File name:
'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr*
methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext,
RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[]
genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord
caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly,
RuntimeModule decoratedModule, MetadataToken decoratedToken,
RuntimeType
attributeFilterType, Boolean mustBeInheritable, Object[]
attributes, IList derivedAttributes, RuntimeType&
attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount,
RuntimeType
attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly
assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type
attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type
attributeType, Boolean inherit)
at Xamarin.Forms.Internals.Registrar.RegisterAll(Type[]
attrTypes)
at Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies)
at PasswordManager.UWP.App.d__1.MoveNext()
知道这可能意味着什么,以及如何解决它吗?
鉴于您的包同时包含 UWP 和桌面组件,您将需要使用 VS 打包项目创建用于商店提交的 .appxupload 文件。
更多info/examples,看这里:
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/
应用商店不再接受混合了 UWP 和 Desktop .NET 二进制文件的包,这些二进制文件不是使用正确的打包项目创建的。这是为了确保 UWP 二进制文件在云中获得正确的 .NET 本机编译(这不适用于桌面 .NET 二进制文件)。在您的情况下,.NET 本机编译在商店中被跳过,导致包无效,因为声明的依赖项与包的内容不匹配。我们应该在此处改进我们的错误检测,以便我们在提交时立即通知您您的包裹不好,需要更多工作。
如果您的 Win32 EXE 不是在 VS 中构建的,而您只是想将二进制文件包含在您的 UWP 项目中,您仍然应该使用打包项目。确保将 Win32 EXE 放入包的子文件夹中。有关此类项目结构,请参见下面的屏幕截图。
我有一个针对 .net 标准 1.4 的 Xamarin.Forms 应用程序。在最低版本为 14393(目标为 16299)的 UWP 应用程序上,我从 Microsoft Store 收到以下异常(尽管在我的计算机上它甚至从 appxbundle
文件运行良好):
注意要点:
- 错误发生在
OnLaunched
中的Xamarin.Forms.Forms.Init(e);
。 - 错误本身是
Could not load file or assembly 'System.Private.CoreLib...'
。
System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) at Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) at PasswordManager.UWP.App.d__1.MoveNext()
知道这可能意味着什么,以及如何解决它吗?
鉴于您的包同时包含 UWP 和桌面组件,您将需要使用 VS 打包项目创建用于商店提交的 .appxupload 文件。
更多info/examples,看这里:
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/
应用商店不再接受混合了 UWP 和 Desktop .NET 二进制文件的包,这些二进制文件不是使用正确的打包项目创建的。这是为了确保 UWP 二进制文件在云中获得正确的 .NET 本机编译(这不适用于桌面 .NET 二进制文件)。在您的情况下,.NET 本机编译在商店中被跳过,导致包无效,因为声明的依赖项与包的内容不匹配。我们应该在此处改进我们的错误检测,以便我们在提交时立即通知您您的包裹不好,需要更多工作。
如果您的 Win32 EXE 不是在 VS 中构建的,而您只是想将二进制文件包含在您的 UWP 项目中,您仍然应该使用打包项目。确保将 Win32 EXE 放入包的子文件夹中。有关此类项目结构,请参见下面的屏幕截图。