user153923
user153923

Reputation:

My UserControl Crashes Visual Studio Whenever I Add It To A Form

I have written a small System.Windows.Forms.UserControl, call it userControl1, that seems to be working the way I want it to.

From within Visual Studio 2010's Designer, I can drag userControl1 from the toolbar and drop it on a Windows Form that I will call testForm1. I can wire-up userControl1, and it works as it should.

However, the purpose of userControl1 is to be able to use it in another UserControl, let's call it userControl2.

From within Visual Studio 2010's Designer, if I drag userControl1 from the toolbar and drop it onto userControl2, Visual Studio 2010 will crash with no message other than it is restarting.

screenshot

At this same time, an Application Error is logged in Event Viewer with Event ID 1000:

Faulting application name: devenv.exe, version: 10.0.40219.1, time stamp: 0x4d5f2a73
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc00000fd
Fault offset: 0x0965f816
Faulting process id: 0x1580
Faulting application start time: 0x01cd90f84338e443
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
Faulting module path: unknown
Report Id: 49ddcedf-fcf8-11e1-8016-00248103a942

How can I go about trying to debug this error? Should I look at something in userControl1 or userControl2?

A few Notes:

Upvotes: 18

Views: 7643

Answers (2)

Lukasz M
Lukasz M

Reputation: 5723

It seems this helped to resolve the issue, so I'm posting it as an answer.

In order to debug your control when used in Visual Studio designer, run two instances of Visual studio and open your project in both instances. Then, in one of the instances use Attach to process... option and attach to the second instance to debug it (devenv.exe process). This way, you should be able to see what the exception is.

Upvotes: 22

bryanbcook
bryanbcook

Reputation: 18328

There likely something in the constructor of your control that is attempting to access another something that isn't available, or is creating an exception that can't be caught by the IDE (StackOverflow, OutOfMemory, etc)

Upvotes: 2

Related Questions