2

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?

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
ispiro
  • 26,556
  • 38
  • 136
  • 291
  • 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 Apr 24 '18 at 22:50
  • 1
    @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 Apr 25 '18 at 11:12

1 Answers1

8

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

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
  • 1
    I'm reading your blog post now. But it already seems different than what I have. I compiled my Win32 code and put the exe in the UWP project. Do I still need the packaging project? (The Win32 exe is built for .net 4.6 so can run on any Windows 10 version.) – ispiro Apr 25 '18 at 15:09
  • 1
    It looks like those links refer to a case where I need to build the 2 projects together. – ispiro Apr 25 '18 at 15:24
  • 1
    I have updated my answer to cover your specific case as well. – Stefan Wick MSFT Apr 25 '18 at 15:33
  • 1
    Thank you for your perseverance. I'll try that. – ispiro Apr 25 '18 at 15:34
  • 1
    `the .NET native compile was skipped in the Store` - doesn't that happen when I create the package in Visual Studio? – ispiro Apr 25 '18 at 18:24
  • 1
    No, that happens when the Store thinks your app is a Desktop Bridge app (since it has the 'runFullTrust' capability). When using the packaging project the Store knows that your app is a UWP with additional desktop components. – Stefan Wick MSFT Apr 25 '18 at 19:03
  • 1
    I wasn't clear. I meant I thought that .net native compilation for UWP happens in VS. (At first I had no idea what you meant in your comment until I realized my comment was ambiguous. It looked like I was referring to the skipping, when I really meant to refer to the .net native compiling.) – ispiro Apr 25 '18 at 19:06
  • 1
    It happens in VS (when yo do release build), and it happens again in the cloud after submission. The .appxupload file you provide will be subject to .NET native compilation as part of the Store ingestion process. That step was skipped for your package, which then results in that error for users obtaining the app from the Store. – Stefan Wick MSFT Apr 25 '18 at 21:18
  • Thanks. Now trying a packaging project and getting errors `PRI277 0xdef00532 - Conflicting values for resource ''` (nothing between the quotes. no line number...) and `Duplicate Entry.` - `error PRI175` (no description or anything). Oh well... – ispiro Apr 25 '18 at 21:41
  • I'll have someone from VS respond to the thread you opened on this resource build issue. – Stefan Wick MSFT Apr 26 '18 at 15:57
  • Thank you very much. But after much testing it turned out to be the 'Assets' folder that was automatically created withing the packaging project. I excluded the folder and that error is gone. – ispiro Apr 26 '18 at 18:57
  • 1
    Now I have the Assets from the UWP project but the title is from the packaging project. Which one is the one I'll be submitting to the store and therefore need to associate with the store etc.? (You didn't get to part 4 of your blog post yet, I see, so I can't find it there.) – ispiro Apr 26 '18 at 19:39
  • 1
    You create the store package off the Packaging project, not the UWP project. So you will need those assets. If there is a conflict between items in the two Asset folder, rename/remove the ones from the UWP project as those won't go in the final package. – Stefan Wick MSFT Apr 26 '18 at 19:47
  • Perfect. Thanks! – ispiro Apr 26 '18 at 19:51