When I run my App in debug mode and configured VS2017 to stop at System.IO.FileNotFoundException I get the exception with message:
'Could not load file or assembly 'clrcompression, Culture=neutral, PublicKeyToken=null'
app runs without any issue
debugger stop in UWP app in app.cs at protected override void OnLaunched(LaunchActivatedEventArgs e)
at line Xamarin.Forms.Forms.Init(e)
System.Private.CoreLib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, System.IntPtr ptrLoadContextBinder) Line 362 C#
System.Private.CoreLib.dll!System.Reflection.Assembly.Load(System.Reflection.AssemblyName assemblyRef) Line 167
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Platform.UWP.WindowsBasePlatformServices.GetAssemblies() Line 63
Xamarin.Forms.Core.dll!Xamarin.Forms.Internals.Registrar.RegisterAll(System.Type[] attrTypes) Line 253
Xamarin.Forms.Platform.UAP.dll!Xamarin.Forms.Forms.Init(Windows.ApplicationModel.Activation.IActivatedEventArgs launchActivatedEventArgs, System.Collections.Generic.IEnumerable<System.Reflection.Assembly> rendererAssemblies) Line 61
foo.App.UWP.exe!foo.App.UWP.App.OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs e)
There is no need for repro, it happens to all users with blank app. It was reported some time ago in old bugtracker, but still occurs.
A workaround is to configure VS to not stop at this exception, but this may hide other issues later in my code.
The source where the issue occurs is here.
Here IOException
and BadImageFormatException
are catched and ignored. So maybe also catch FileNotFoundException
here or check for clrcompression and skip loading it.
Feature request for Just-My-Code debugging.
Yeah, I'm getting the same issue. Very strange behaviour. The UWP project was working fine and then suddenly, this started occurring but I can't find a way to stop it from happening.
@jamie-lord
in exception settings uncheck to stop at System.IO.FileNotFoundException
I had the same issue as well and fixed it. I was able to fix the issue by:
Properties -> Build -> Enable "Compile with .NET Native tool chain"
@yschang nope, still the same issue, also native runtime has a clrcompression.dll
Can you try it on Visual Studio 2019? Also, can you update all of your Nuget packages from your UWP project?
I now no longer get missing clrcompression.dll
, now VS stops with Could not load file or assembly 'Microsoft.Graphics.Canvas, Culture=neutral, PublicKeyToken=null'
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'Microsoft.Graphics.Canvas, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
Source=System.Private.CoreLib
StackTrace:
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) in E:\A\_work\414\s\src\mscorlib\src\System\Reflection\RuntimeAssembly.cs:line 353
and missing ucrtbased.dll
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'ucrtbased, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
Source=System.Private.CoreLib
StackTrace:
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) in E:\A\_work\414\s\src\mscorlib\src\System\Reflection\RuntimeAssembly.cs:line 353
But both can be found in C:\Users\USERNAME\AppData\Local\DevelopmentFiles\Foo.App.UWPVS.Debug_x86.USERNAME
🤔 🤷♂️
I also get this one now after updating to 4.3.0.947036
at Xamarin.Forms.Forms.Init(e);
System.TypeLoadException
HResult=0x80131522
Message=Error 0x261F. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.30319.0&File=mscorrc.dll&Key=0x261F
Source=System.Private.CoreLib
StackTrace:
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
Inner Exception 1:
COMException: Klasse nicht registriert (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
🤔 🤷♂️
I now also get a System.IO.FileNotFoundException in Xamarin.Forms.Platform.UAP.dll without any details:
Exception thrown: 'System.IO.FileNotFoundException' in Xamarin.Forms.Platform.UAP.dll
Das System kann die angegebene Datei nicht finden. (Exception from HRESULT: 0x80070002)
And this is the stack
Thank you! This fixed it for me! :-)
I had the same issue as well and fixed it. I was able to fix the issue by:
Properties -> Build -> Enable "Compile with .NET Native tool chain"
I am having the same issue. The suggestion to enable "Compile with .NET Native tool chain" did not help.
I am having the same error about Microsoft.Graphics.Canvas, and it is driving me NUTS.
It is the first dll mentioned in a list of Extensions in AppX\AppxManifest.xml, and the dll is actually THERE.
I have also checked System.IO.Directory.GetCurrentDirectory(), which is THERE.
It crashes at the mentioned Xamarin.Forms.Forms.Init(e).
I tried Compile with .NET Native tool chain, but that did not even compile.
Frustrating is that newly created Xamarin solution including an UWP target DOES run, having exactly the same list of extensions. I have been comparing the references, the project files, UWP\Package.appxmanifest, and AppX\AppxManifest.xml. None of that brought me any further.
This is just a first chance exception you're seeing. It's a byproduct of assembly scanning but it shouldn't crash the application
Is your application failing to launch?
@a-einstein it sounds like your exception is different than what is posted here. Can you create a new issue? @jsuarezruiz FYI
PureWeen, if you are addressing me: yes it crashes on the Canvas, followed by ucrtbased, and then a lot of 'EventLog access is not supported on this platform.'
And my situation is very similar to ones mentioned previously. Read the details.
Most helpful comment
I had the same issue as well and fixed it. I was able to fix the issue by:
Properties -> Build -> Enable "Compile with .NET Native tool chain"