2
votes

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?

1
Does your app use a desktop extension component and if so did you use the VS Packaging Project to create the store package? The error indicates that you have submitted an invalid package.Stefan Wick MSFT
@StefanWickMSFT Nice work! Yes indeed, I have a desktop extension. But I did not create the project using the packaging project as it's not a Centennial app. It's a Xamarin.Forms app. I have, though, included a Win32 (Winforms) app that is called (not on startup, only by user action) from the app using await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();. I have received the permission from the Centennial team, and the Win32 exe is called fine on my computer.ispiro

1 Answers

8
votes

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.

enter image description here