Strange FileLoadExceptions

Gavin Williams 716 Reputation points
2020-03-16T05:25:41.62+00:00

I have a small program that was working, I was generating assets in the manifest. Then I renamed the project, it also uses another library project of mine. Now it's not working, and I'm getting a lot of FileLoadExceptions as follows:

T: 3 | Graphics.Ctor T: 3 | Dx11.CreateDeviceResources T: 3 | RenderSurface.Ctor T: 3 | RenderSurface.BuildAsync T: 3 | MaterialTexture.BuildDefaultResourcesAsync Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll T: 3 | RasterizerStatePrefabs.BuildSolid T: 3 | RasterizerStatePrefabs.BuildWireframe Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll The program '[17656] UWPCameraPan.exe' has exited with code 1 (0x1).

I've seen many exceptions generated for each file exception, so there may be just 1 file issue and then all these errors being spat out. The Xaml runs but my code is crashing out. How can i debug this?

Universal Windows Platform (UWP)
{count} votes

3 answers

Sort by: Most helpful
  1. Gavin Williams 716 Reputation points
    2020-03-25T02:51:01.92+00:00

    This started happening a week or so ago. I thought I'd stuffed something up, so I rebuilt a small project with just this one call to load a texture, and it's still happening. I'm starting to think this isn't my code and something in Visual Studio has broken. When i try to step into a function that is throwing the exception, the exception is thrown before any user code is executed in the function. I've put a break point on the first line in that fn and it's never reached.

    public static async Task<Texture> LoadTextureAsync(string debugName, Folders folder, string filePath)
    {
    BitmapSource bitmapSource = await LoadBitmapSourceAsync(folder, filePath);
    

    When i try to step into the LoadBitmapSourceAsync method, having put a breakpoint inside that method on the first line of code I get the following output ..

    Step into: Stepping over non-user code 'Engine.Core.FileIo.LoadBitmapSourceAsync'

    Step into: Stepping over non-user code 'Engine.Core.FileIo.<LoadBitmapSourceAsync>d__5..ctor'

    Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll

    And execution has returned out to

    Texture texture = await FileIo.LoadTextureAsync(&#34;DebugTexture&#34;, Folders.Installation, &#34;Assets\\DwarfPortrait.png&#34;);
    

  2. Gavin Williams 716 Reputation points
    2020-03-25T04:12:14.277+00:00

    This is in debug mode. Changed to mixed mode debugging. This app does potentially call SharpDX. Although no SharpDX code get's a chance to run in this case. When i turned on mixed mode debugging, I get some extra output .. (note: I changed namespace here from core to serialization, it's not relevant, it was just a tidy up as i was looking through it)

    Step into: Stepping over non-user code 'Engine.Serialization.FileIo.LoadBitmapSourceAsync'
    Step into: Stepping over non-user code 'Engine.Serialization.FileIo.<LoadBitmapSourceAsync>d__5..ctor'
    Exception thrown at 0x76BF4192 in DemoLoadingData.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0993B93C.
    Exception thrown at 0x76BF4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown at 0x76BF4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown at 0x76BF4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.dll

    Further, this started happening across projects after I tried to prepare a small app for submission to the store. So I may have run some package generation tools in Visual Studio.

    I don't get any Exception popups, i guess the exception is not being caught, and execution is falling out to the first calling function.

    So when I run it in release, my breakpoint inside the LoadBitmapSourceAsync method is hit and i can step through the code without those exception. It seems to run normally until it reaches, in this case, an expected NullReferenceException, because I haven't setup WIC Factory.

    I didn't even know breakpoints would work in release mode.

    It only happens in Debug. I checked my other project and it's the same, it's working in release.


  3. Gavin Williams 716 Reputation points
    2020-03-26T11:39:33.357+00:00

    Alright, after a little detour thinking I'd uncovered a related issue, and having it pointed out that I was doing something wrong, I've realized that this is complicated and there's a lot of my own convoluted code in between what's happening and a fix. So I'm working on isolating the problem and double checking my code here and there. This rings of an issue with async code where things can look good for a long time and suddenly stop working. I also got this error tonight ..

    WinRT originate error - 0x80131040 : 'System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.15.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference.

    So I'll post again after I've worked through a couple of things and when I can perhaps present a much clearer and minimal picture of the issue.