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

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

问题描述

我有一个针对.net标准1.4的Xamarin.Forms应用。在最低版本为14393(目标为16299)的UWP应用上,我从Microsoft Store获得以下异常(尽管在我的计算机上,即使从 appxbundle 文件运行起来也很好) :



注意要点:


  1. 错误发生在 Xamarin.Forms.Forms.Init(e); OnLaunched 中。

  2. 错误本身是无法加载文件或程序集'System.Private.CoreLib ...'




System.IO.FileNotFoundException:无法加载文件或程序集
'System.Private.CoreLib,Version = 4.0.0.0,Culture =中性,
PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。
系统找不到指定的文件。文件名:
'System.Private.CoreLib,Version = 4.0.0.0,Culture = neutral,
PublicKeyToken = b03f5f7f11d50a3a'
位于System.ModuleHandle.ResolveType(RuntimeModule模块,Int32 typeToken,IntPtr * typeInstArgs,Int32 typeInstCount,IntPtr * )System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,Type [] genericTypeArguments,Type []
genericMethodArguments)中的
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord
caRecord ,MetadataImport范围,Assembly& lastAptcaOkAssembly,
RuntimeModule装饰模块,MetadataToken装饰令牌,
RuntimeType
attributeFilterType,布尔值mustBeInheritable,对象[]
属性,IList派生属性,RuntimeType&
attributeType,IRuntimeMethodInfo& ctor,布尔值和放大器; ctorHasParameters,布尔值和isVarArg)
在System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
装饰模块,Int32装饰性元数据令牌,Int32 pcaCount,
RuntimeType
attributeFilterType,布尔值mustBeInheritable,IList派生属性,布尔值isDecoratedTargetSecurityTransparent)
在System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly
程序集,RuntimeType caType)
在System.Reflection.RuntimeAssembly.GetCustomAttributes(类型
attributeType,布尔值继承)
在System .Attribute.GetCustomAttributes(组合元素,类型
attributeType,布尔值继承)
在Xamarin.Forms.Internals.Registrar.RegisterAll(Type []
attrTypes)
在Xamarin.Forms .Forms.Init(IActivatedEventArgs launchActivatedEventArgs,IEnumerable`1 rendererAssemblies)
在PasswordManager.UWP.App.d__1.MoveNext()


任何想法这可能

解决方案

鉴于您的软件包同时具有UWP和Desktop组件,您将需要使用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天全站免登陆