无法加载文件或程序集“System.Private.CoreLib..." [英] Could not load file or assembly 'System.Private.CoreLib...'

查看:61
本文介绍了无法加载文件或程序集“System.Private.CoreLib..."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个面向 .net 标准 1.4 的 Xamarin.Forms 应用程序.在最低版本为 14393(并以 16299 为目标)的 UWP 应用程序上,我从 Microsoft Store 收到以下异常(尽管在我的计算机上它甚至从 appxbundle 文件中也能正常运行):

注意要点:

  1. OnLaunched 中的 Xamarin.Forms.Forms.Init(e); 上发生错误.
  2. 错误本身是无法加载文件或程序集System.Private.CoreLib...".

<块引用>

System.IO.FileNotFoundException: 无法加载文件或程序集'System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一.这系统找不到指定的文件.文档名称:'System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a'在 System.ModuleHandle.ResolveType(RuntimeModule 模块,Int32 typeToken,IntPtr* typeInstArgs,Int32 typeInstCount,IntPtr*methodInstArgs、Int32 methodInstCount、ObjectHandleOnStack 类型)在 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块,Int32 typeToken,RuntimeTypeHandle[] typeInstantiationContext,RuntimeTypeHandle[] methodInstantiationContext)在 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[]泛型方法参数)在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecordcaRecord、MetadataImport 范围、Assembly&lastAptcaOkAssembly,RuntimeModule 装饰模块、元数据令牌装饰令牌、运行时类型属性过滤器类型,布尔值 mustBeInheritable,对象 []属性,IList 派生属性,RuntimeType&属性类型、IRRuntimeMethodInfo&ctor, Boolean&ctorHasParameters, Boolean&isVarArg)在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule装饰模块,Int32 装饰元数据令牌,Int32 pcaCount,运行时类型attributeFilterType,布尔值 mustBeInheritable,IList 派生属性,布尔值 isDecoratedTargetSecurityTransparent)在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly程序集,运行时类型 caType)在 System.Reflection.RuntimeAssembly.GetCustomAttributes(Type属性类型,布尔继承)在 System.Attribute.GetCustomAttributes(Assembly 元素,类型属性类型,布尔继承)在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[]属性类型)在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies)在 PasswordManager.UWP.App.d__1.MoveNext()

任何想法这可能意味着什么,以及如何解决它?

解决方案

鉴于您的包同时具有 UWP 和桌面组件,您将需要使用 VS Packaging Project 来创建用于商店提交的 .appxupload 文件.

有关更多信息/示例,请查看此处:

I have a Xamarin.Forms app which targets .net standard 1.4. On the UWP app which has minimum version 14393 (and targets 16299) I get the following exception from the Microsoft Store (though on my computer it runs fine even from the appxbundle file):

Note the main points:

  1. The error occurs on Xamarin.Forms.Forms.Init(e); in OnLaunched.
  2. The error itself is 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()

Any ideas what this might mean, and how to solve it?

解决方案

Given that your package has both UWP and Desktop components, you will need to use the VS Packaging Project for creating the .appxupload file for Store submission.

For more info/examples, look here:

https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

https://blogs.windows.com/buildingapps/2017/12/04/extend-desktop-application-windows-10-features-using-new-visual-studio-application-packaging-project/ (see example #3)

The Store no longer accepts packages with mixed UWP and Desktop .NET binaries that have not been created with the proper packaging project. This is to ensure the UWP binaries get the proper .NET native compile in the cloud (which is not applicable to the Desktop .NET binaries). In your case what happened is that the .NET native compile was skipped in the Store, resulting in an invalid package as the declared dependencies don't match the content of the package. We should improve our error detection here, so that we notify you right at submission time that your package is not good and needs more work.

If your Win32 EXE is not built in VS and you just want to include the binary in your UWP project you should still use the Packaging project. Make sure the Win32 EXE gets dropped into a subfolder of the package. See screenshot below for this type of project structure.

这篇关于无法加载文件或程序集“System.Private.CoreLib..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆