Multiple Strange errors with Visual Basic - Failed to set Win32 parent window of the Control

Viewed 586

I am using Visual Studio 2019, creating a Visual basic Project using "Windows Forms App (.NET)" as the project template.

This happens right after I create the project and haven't added any additional code. When I try and create a textbox on the form, Visual Studio provides the following error (ERROR 1):

FailedToCreateComponentError

Also, the following error comes up if I try and drag the control from the ToolBox directly onto the default form (ERROR 2):

ObjectRefrenceNotSet

The key part of this error from what I can tell is "Failed to set Win32 parent window of the Control." I was previously trying to create some mobile apps using Xamarin (mentioned this because xmarin had a buggy GUI) however, this is happening after rebooting the machine, starting up visual studio, and creating a project using "Windows Forms App (.NET)" as the project template. This has worked in the past so it's coincidental it started happening after I was trying to use xmarin in a separate project/solution.

====

UPDATE: When creating a project template using "Windows Forms App (.NET Framework)", with the added "Framework" at the end, I'm able to draw the textbox on the form (First error is not happening). Still not able to drag directly onto the form. Still getting the second error "Object Reference not set to an instance of an object".

Not sure what the difference between "Windows Forms App (.NET Framework)" and "Windows Forms App (.NET)" is in the project templates.

====

Any help or ideas please let me know.

Jeff

2 Answers

As @Jeff82 and @jmcilhinney noted in the question comments, this appears to be caused by one of, or a combination of, DPI scaling and using Visual Studio on a non-primary monitor. These steps resolved it for me:

  1. Close the form on which you're trying to place the control
  2. Move Visual Studio to your primary monitor
  3. Open the form again

I resolved this by chance. Really happy this is resolved as it was preventing me from doing more tasks within Visual Studio. To anyone else that may be having this issue, I am using 3 monitors. I had these monitors configured to different Scale and Layout Settings. In doing so, it looks like it confused visual studio whom was trying to use the settings from the primary display.

To resolve this, I set the "Scale and Layout" setting to the same on each monitor.

enter image description here

I set this back to 100% on each monitor which resolved the issue.

-Jeff

Related