SwapChainPanel.SizeChanged crashing

Gavin Williams 761 Reputation points
2020-03-26T16:00:36.497+00:00

Related to https://learn.microsoft.com/answers/questions/13613/strange-fileloadexceptions.html

If I subscribe to SwapChainPanel.SizeChanged with an empty method, it resizes. But if i have a line of code in there with a breakpoint the app crashes. Am I not understanding something here?

This will run and resize ..

private void SwapChainPanel_SizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)  
{  
    //HostSize = new IntSize((int)e.NewSize.Width, (int)e.NewSize.Height);  
}  

This will crash ..

private void SwapChainPanel_SizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)  
{  
    HostSize = new IntSize((int)e.NewSize.Width, (int)e.NewSize.Height); ** BREAKPOINT SET **  
}  

Output ..

onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!513C44D2: (caller: 513C4327) ReturnHr(1) tid(5688) 80070490 Element not found.
onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!513C44D2: (caller: 513C4327) ReturnHr(2) tid(5688) 80070490 Element not found.
Exception thrown at 0x76BB4192 in DemoLoadingData.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0947CDBC.
Exception thrown at 0x76BB4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x76BB4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x76BB4192 in DemoLoadingData.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x76BB4192 (KernelBase.dll) in DemoLoadingData.exe: 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. (Exception from HRESULT: 0x80131040)
at Engines.Engine2.SwapChainPanel_SizeChanged(Object sender, SizeChangedEventArgs e)'.
The program '[5180] DemoLoadingData.exe' has exited with code 0 (0x0).

Universal Windows Platform (UWP)
{count} votes

2 answers

Sort by: Most helpful
  1. Gavin Williams 761 Reputation points
    2020-03-30T08:54:09.503+00:00

    I'm going to reopen this ... now I'm getting the same crash for a different event - OnPointerMoved ...

    Exception at 0x75864192 in Demo.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x12DDD0EC.
    Exception at 0x75864192 in Demo.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception at 0x75864192 (KernelBase.dll) in Demo.exe: 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. (Exception from HRESULT: 0x80131040) at Engine.Interaction.MouseEventProcessor.OnPointerMoved(Object sender, PointerEventArgs e)'.

    I noticed that the app that works has my engine code dragged over to the project, while the two apps that crash are using a library. I'm going to setup two identical projects with just this difference to test.

    The page wouldn't let me say this as a comment - these forums are really bad.


  2. Gavin Williams 761 Reputation points
    2020-03-31T05:45:43.57+00:00

    From : https://github.com/dotnet/runtime/issues/34309

    Why are there 3 very similarly named packages?

    System.Runtime.InteropServices.Windows.Runtime (4.3.0)
    System.Runtime.InteropServices.WindowsRuntime (4.3.0)
    System.Runtime.WindowsRuntime (4.7.0)
    If System.Runtime.WindowsRuntime (4.7.0) is used, the app will actually crash as events will be wired up to the wrong assembly. The following output will be produced ...

    Exception thrown at 0x75864192 in Demo.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x1296D25C.

    Exception thrown at 0x75864192 in Demo.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.

    Exception thrown at 0x75864192 in Demo.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.

    Exception thrown at 0x75864192 in Demo.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.

    Exception thrown at 0x75864192 (KernelBase.dll) in Demo.exe: 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. (Exception from HRESULT: 0x80131040)
    at Engine.Interaction.MouseEventProcessor.OnPointerMoved(Object sender, PointerEventArgs e)'.

    But WindowsRuntime 4.7.0 looks like the current version of WindowsRuntime 4.3.0 - and no idea why there is also a Windows.Runtime 4.3.0 - This is all a big screw-up if you ask me. We have to guess which one to use. Because when a project is setup in VS, they are not automatically added, events just won't compile with red-squigglies. I've just spent a week trying to find this bug.

    Oh, and System.Runtime.InteropServices.WindowsRuntime (4.3.0) is only needed if events are used in a DLL (.net standard), because I suppose the Universal Windows package does actually include the right whatever. This is a minefield.

    Is there any documentation about this?