question

DeadStack avatar image
0 Votes"
DeadStack asked FayWang-MSFT commented

SwapChainPanel.SizeChanged crashing

Related to https://docs.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).

windows-uwp
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I created a blank project and subscribe SizeChanged event, when I added a line of code int it, the app didn't crash. What did you do in the IntSize class? If you add other code(e.g. int aa = (int)e.NewSize.Width;), will the same issue occur? Can you please provide a simple sample that can be reproduced for us to test?

0 Votes 0 ·

So this will crash too ..

         private void SwapChainPanel_SizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
         {
             int w = (int)e.NewSize.Width;
             int h = (int)e.NewSize.Height;
         }


But when i take my graphics code out of the project. It resizes. I'll look into that.

0 Votes 0 ·

OK, if you have any progress, please update.

0 Votes 0 ·
Show more comments

Wow, the form just trashed my response. I'm not writing it again. This issue is closed.


Edit: I wasn't able to reproduce this issue outside of the original project that I saw it. Terrible error message - it makes it sound like the project isn't set up properly. Can we please have error messages that are actually meaningful.


0 Votes 0 ·

For debugging, you can load debugging symbols for code that does not currently have symbols loaded. Choose Debug options->Debugging->Symbols, select Microsoft Symbol Servers or browse to the symbol path, remember to add a cache directory to cache symbols. Then click the General->disable "Just My Code", in this case, it won't hide non-user code frames. After that, compile the project again, will more information about error occur? In addition, about the complete steps, you can refer to this document.


0 Votes 0 ·
DeadStack avatar image
0 Votes"
DeadStack answered DeadStack commented

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.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So I'm rebuilding a .net standard class library with the basics of my framework. I'm being told that ..

CS1545 Property, indexer, or event 'FrameworkElement.SizeChanged' is not supported by the language; try directly calling accessor methods 'FrameworkElement.add_SizeChanged(SizeChangedEventHandler)' or 'FrameworkElement.remove_SizeChanged(EventRegistrationToken)' E:\Dev\Projects\UWPSamples\MinimalEngine\Core\Engine.cs


Also, none of the mouse events are recognized either. What is the correct thing to do here?

Notice that these are all the events that are causing the crash too.

6751-annotation-2020-03-31-013841.jpg


0 Votes 0 ·

Do you mean the project where the SizeChanged event of SwapChainPanel crashes is referencing a .net standard class library? Can you provide a simple sample that can be reproduced for us to test?

0 Votes 0 ·

Yes, I can provide a sample, I just need to put it together. I've created a mini-engine project so that i don't need to send everything.

0 Votes 0 ·
DeadStack avatar image
0 Votes"
DeadStack answered FayWang-MSFT commented

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?

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If you put your Target Version and Min Version to Fall Creators Update and test it again, will the same issue occur?

0 Votes 0 ·

If i set both to Fall Creators Update and remove System.Runtime.InteropServices.WindowsRuntime 4.3.0, the CoreWindow and FrameworkElement events that I use are still not supported by the language. I'm using Microsoft.Windows.SDK.Contracts.

0 Votes 0 ·

I added the Microsoft.Windows.SDK.Contracts nuget package and tried to add FrameworkElement events, it also throwed 'no supported' issue. If you want to use windows runtime apis in class library, you could try to create a class library(Universal windows) instead of .net standard to use it.

0 Votes 0 ·