Open MagicAndre1981 opened 5 years ago
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.
Any updates on this?
Any updates on this?
I disabled the debugger to stop at System.IO.FileNotFoundException and ignore the message in VS output. In MAUI, UWP get replaced with WinUI3, so they don't care about UWP any longer.
Hello. I've just had this issue re-appear with latest version of VS2019 and Xamarin Forms (2083). "Message=Could not load file or assembly 'Microsoft.Graphics.Canvas, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified". The previous work-around of enable native tool chain not working.
The thing is, I created a new app to test some of my library pages (as it first happened when trying to add one of my library pages - the page only had a label in it so far, so shouldn't have been any issue). I did this because the issue then started happenning with some of my other pages which I hadn't touched. So I created this test app, and first few pages I added to it worked, then I struck one that wasn't working, and none of the rest worked either. Then I went back to one which had been working, and it wasn't working anymore either! It even crashes now on a page which is in the same project. It looks like something happens to corrupt things in your project, and then you're stuck. Doing a clean didn't fix it.
Found a solution at https://stackoverflow.com/questions/58346806/xamarin-microsoft-netcore-universalwindowsplatform-v6-2-9-fails - delete the .vs folder! For the libraries, I had to delete their .vs folder too.
Found a solution at https://stackoverflow.com/questions/58346806/xamarin-microsoft-netcore-universalwindowsplatform-v6-2-9-fails - delete the .vs folder! For the libraries, I had to delete their .vs folder too.
NO, this only resets the VS options for the solution and removes the exception settings so that VS no longer breaks at the the FileNotFoundException.
Found a solution at https://stackoverflow.com/questions/58346806/xamarin-microsoft-netcore-universalwindowsplatform-v6-2-9-fails - delete the .vs folder! For the libraries, I had to delete their .vs folder too.
NO, this only resets the VS options for the solution and removes the exception settings so that VS no longer breaks at the the FileNotFoundException.
No. After reading your comment I had a look. I can see that you're partly right in that there is still one FileNotFound Exception there, HOWEVER, it's NOT the one that was causing my app to crash. The only exception there now, having deleted the .vs folder, is "Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll", and that wasn't the one causing my app to crash, so it's not clearing ALL FileNotFound exceptions, but it's clearing the one which was causing the crash (the Microsoft.Graphics.Canvas one). Why it's doing that is another matter, but that is definitely what is happenning on my machine (it's also solved another issue I had on my machine which had a different error message - couldn't find my library that I had linked to. After deleting the .vs folder it now finds it. As per the comment in that StackOverflow issue "causing random runtime library resolution problem", and it's definitely random, cos it's now solved 2 different error messages for me... and there's a 3rd I'm going to try again tonight to see if it solves that one too).
BTW interesting twist, when I checked to break on FileNotFoundException, that made the app-crashing exception (the Canvas one) come back!
P.S. to be clear, when I say crash, I mean crash. Not "break at exception". With break at exception unchecked, my app will crash with the Canvas not found exception message (or another exception message). Deleting .vs folders clears it and app works again.
@PureWeen
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?
That's an interesting comment that you mention first chance exceptions, as I have code in my app to catch those (i.e. AppDomain.CurrentDomain.FirstChanceException+=CurrentDomain_FirstChanceException;), so I investigated some more. When I check break on exception, my code does catch all those first chance exceptions, but when I uncheck break on exception they are no longer there! I would've expected them to still be there regardless of break checked/unchecked in VS, but they seem to appear only when break is checked.
Just wasted a week because of this bogus FileNotFoundException: ''
occurring when an actual other exception is being thrown. The call stack always seems to show an attempted load of satellite / localization assemblies, possibly looking up an error text or something similarly stupid, which fails.
I almost gave up on the whole .NET 6.0 / Xamarin stuff again until I realized I have to press F5 one or more times until I get the actual exception.
It only occurs on a real device and not the emulator for me.
Just wasted a week because of this bogus
FileNotFoundException: ''
occurring when an actual other exception is being thrown. The call stack always seems to show an attempted load of satellite / localization assemblies, possibly looking up an error text or something similarly stupid, which fails.I almost gave up on the whole .NET 6.0 / Xamarin stuff again until I realized I have to press F5 one or more times until I get the actual exception.
It only occurs on a real device and not the emulator for me.
@RayKoopa damn bro, thank you! This System.IO.FileNotFoundException: ''
forced me to write code just for debugging. As you can see - still not fixed.
Description
When I run my App in debug mode and configured VS2017 to stop at System.IO.FileNotFoundException I get the exception with message:
Steps to Reproduce
Expected Behavior
app runs without any issue
Actual Behavior
debugger stop in UWP app in app.cs at
protected override void OnLaunched(LaunchActivatedEventArgs e)
at lineXamarin.Forms.Forms.Init(e)
Basic Information
Screenshots
Reproduction Link