Xamarin UWP Debug Build works, but not Release ("No embeddedresource found" and .NET Native Toolchain)

2

So I have now finished coding for my Xamarin Application and all works fine in the Debug builds. I've then tested the Release build on Android by Archiving and Signing the APK, and it works fine, but the problem comes in when trying to Build the UWP Project Package Files. If I try to start the program then I get the following Exception:

+       $exception  {Xamarin.Forms.Xaml.XamlParseException: No embeddedresource found for AppPrescribe.App
   at Xamarin.Forms.Xaml.XamlLoader.Load(Object view, Type callingType)
   at AppPrescribe.UWP.MainPage..ctor() in D:\Xamarin\P\AppPrescribe\AppPrescribe\AppPrescribe.UWP\MainPage.xaml.cs:line 26
   at AppPrescribe.UWP.AppPrescribe_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage() in D:\Xamarin\P\AppPrescribe\AppPrescribe\AppPrescribe.UWP\obj\x86\Release\XamlTypeInfo.g.cs:line 255
   at Xamarin.Forms.Platform.UAP.Xamarin_Forms_Platform_UAP_XamlTypeInfo.XamlUserType.ActivateInstance()
   at __Interop.ReverseComStubs.Stub_19(Object __this, Void** unsafe_returnValue__retval, IntPtr __methodPtr)}  Xamarin.Forms.Xaml.XamlParseException

I'm also returned to my UWP Project, inside the MainPage.xaml.cs file, and my cursor is placed next to LoadApplication(new AppPrescribe.App()); inside the MainPage Constructor.

And if I try to go ahead with Creating the App Packages, the Application crashes multiple times during the Test phases. (Again, I changed no code between Debug and Release)

What am I missing here? Forgive me if it's a dumb solution.

I've tried:

  • removing and re-adding the reference to my .NET Class Library with the shared code, then do a Clean and Rebuild
  • Deleted bin and obj files, do a Clean and Rebuild
  • uninstalled Debug App and do Clean and Rebuild

but I still get the same error.

EDIT: If I uncheck "Compile with .NET Native tool chain" then the app compiles fine and runs in debug, but then I cannot create the App package because Windows App Certification fails the Binary Analyzer side of the testing. If I leave it checked (along with Optimize Code) and then debug, the Application goes into Break Mode and I get this Exception:

Unhandled exception at 0x101F43FA (Windows.UI.Xaml.dll) in DisChemPrescribe.UWP.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0352CD90, 0x00000002).

c#
xaml
xamarin
xamarin.forms
xamarin.uwp
asked on Stack Overflow Mar 12, 2018 by Cyfer • edited Mar 12, 2018 by Cyfer

1 Answer

0

That happens when you update PCL projects into .Net Standard. If you open a PCL's csproj file you'll see Xaml and Xaml.cs connections like

</Compile>
    <Compile Include="OverviewPage.xaml.cs">
    <DependentUpon>Overview.xaml</DependentUpon>
</Compile>

However, once you migrate your PCL to .Net Standard this connections dissapears.

There are 2 solution to fix this issue (afaik).

Add embedded resource definiton to csproj file

  <EmbeddedResource Update="OverviewPage.xaml">
    <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
  </EmbeddedResource>

Use Xaml Compilations: Add Xaml compilation tag for all xaml.cs files

[XamlCompilation(XamlCompilationOptions.Compile)]
answered on Stack Overflow Mar 14, 2018 by eakgul

User contributions licensed under CC BY-SA 3.0