Resolved ?? Exception thrown: 'System.InvalidOperationException' in PresentationFramework.dll

GregJ7

Member
Joined
Nov 23, 2024
Messages
12
Programming Experience
10+
I built a simple app to draw a 30x30 grid of lines (30x31x2 individuals lines, not drawn as 30x30 rectangles). The first attached file is a snapshot of it running. It can be resized and the grid dynamically resizes with it. Then I discovered that XAML was causing me more trouble for logically structuring my code than I found acceptable, so I (following some YouTube directions) built an empty WPF app and deleted the .xaml files and their associated code behind .cs files. I added a entry point class and Main() and it would build and run. So I added back much of the code to draw the grid. Now I am getting a really esoteric bug, which I attribute to my project settings, because I have seen the code work (although I have since changed it somewhat), but I am several thousand hours short of the experience needed to figure out what is wrong.

Exception thrown: 'System.InvalidOperationException' in PresentationFramework.dll
The program '[34696] Test.exe' has exited with code 3221226525 (0xc000041d).

The exception is thrown in a call to a Window's AddChild(). There is no normal Exception dialog box. It just exits silently with the above lines of output.

It is the second time AddChild() is called that I get the error. If I stop adding children after the first time, the grid (with just one line) displays correctly.

I have attached a .zip of the solution. If anyone can spend a little time looking at this, I would greatly appreciate it. There is no apparent way forward for me to debug it myself. I'm not going to be able to learn the under-the-hood details of project settings, dependencies, and references anytime soon.
 

Attachments

  • Output.jpg
    Output.jpg
    390.2 KB · Views: 2
  • Test.zip
    4.8 KB · Views: 1
How did you resolve the issue?
 
By deciding I needed to learn how to build a WPF VS project up from an empty .NET project. Other people that have gotten the error in this base post never found out what the problem was.
 
Back
Top Bottom