无法加载文件或程序集'System.Private.CoreLib ...'

isp*_*iro -1 c# xamarin uwp .net-standard desktop-bridge

我有一个针对.net标准1.4的Xamarin.Forms应用程序.在具有最低版本14393(和目标16299)的UWP应用程序上,我从Microsoft Store获得以下异常(尽管在我的计算机上它甚至从appxbundle文件运行良好):

注意要点:

  1. 发生在错误Xamarin.Forms.Forms.Init(e);OnLaunched.
  2. 错误本身就是Could not load file or assembly 'System.Private.CoreLib...'.

System.IO.FileNotFoundException:无法加载文件或程序集'System.Private.CoreLib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一.该系统找不到指定的文件.文件名:System.ModuleHandle.ResolveType的'System.Private.CoreLib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'(RuntimeModule模块,Int32 typeToken,IntPtr*typeInstArgs,Int32 typeInstCount,IntPtr*methodInstArgs,Int32 methodInstCount System.FoduleHandle.ResolveTypeHandleInternal(RuntimeModule模块,Int32 typeToken,RuntimeTypeHandle [] typeInstantiationContext,RuntimeTypeHandle [] methodInstantiationContext),System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,Type [] genericTypeArguments,Type [] genericMethodArguments)at,SystemHandleOnStack type) System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,MetadataImport范围,Assembly&lastAptcaOkAssembly,RuntimeModule decoratedModule,MetadataToken decoratedToken,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object [] attributes,IList derivedAttributes,RuntimeType&attributeType,IRuntimeMethodInfo&ctor,Boolean&ctorHasParameters ,布尔逻辑isVarArg)处System.Reflection.CustomAttribute.GetCustomAttributes System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule,的Int32 decoratedMetadataToken,的Int32 pcaCount,RuntimeType attributeFilterType,布尔mustBeInheritable,IList的derivedAttributes,布尔isDecoratedTargetSecurityTransparent)(RuntimeAssembly组件,RuntimeType caType)在System.Attribute.GetCustomAttributes(Assembly element,Type attributeType,Boolean inherit)的System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType,Boolean inherit)位于Xamarin.Forms的Xamarin.Forms.Internals.Registrar.RegisterAll(Type [] attrTypes) PasswordManager.UWP.App.d__1.MoveNext()中的.Forms.Init(IActivatedEventArgs launchActivatedEventArgs,IEnumerable`1 rendererAssemblies)

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

Ste*_*SFT 6

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

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

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/(参见示例#3)

Store不再接受具有未使用正确打包项目创建的混合UWP和Desktop .NET二进制文件的包.这是为了确保UWP二进制文件在云中获得正确的.NET本机编译(这不适用于Desktop .NET二进制文件).在您的情况下,发生的事情是在Store中跳过.NET本机编译,导致无效的包,因为声明的依赖项与包的内容不匹配.我们应该在这里改进我​​们的错误检测,以便我们在提交时通知您包裹不好并需要更多工作.

如果您的Win32 EXE不是在VS中构建的,并且您只想在UWP项目中包含二进制文件,那么您仍应使用Packaging项目.确保Win32 EXE被放入包的子文件夹中.有关此类项目结构,请参见下面的屏幕截图

在此输入图像描述