I'm trying to open a user control in one of our projects. It was created, I believe, in VS 2003, and the project has been converted to VS2008. I can view the code fine, but when I try to load the designer view, VS stops responding and I have to close it with the task manager. I have tried leaving it running for several minutes, but it does not do anything. I ran "devenv /log" but didn't see anything unusual in the log. I can't find a specific error message anywhere. Any idea what the problem might be? Is there a lightweight editing mode I might be able to use or something?
The reason I need to have a look at the visual representation of this control is to decide where to insert some new components.
I've tried googling it and searching SO, but either I don't know what to search or there is nothing out there about this. Any help is appreciated.
(The strangest thing is that the user control seems to load fine in another project which references, but VS crashes as soon as I even so much as click on it in that project.)
EDIT
The user control is a wrapper of a 3rd party HTML editor...so not exactly something which accesses a database.
I just tried putting the control on a new project and it crashed as soon as I dragged it onto the form.
Hangs like these are usually associated with networking. A database perhaps. You have to watch out for code that runs inside the UserControl at design time. Not just the constructor, also the Load event, timers, OnHandleCreated, OnResize, etcetera. The way to avoid running that code is by testing the DesignMode property, don't do anything dangerous when it is true.
Your ultimate fallback is to debug the code at design time with another instance of Visual Studio.
After all that you have done, I would also try to load the user control in a brand new project, and see if it loads correctly; and if it does, then you can "decide where to insert some new components"... just thinking out loud!
To me helps changing Target Framework from ".Net Framework 4 Client Profile" to ".Net Framework 4" in project settings.
I had the same problem. In my case, the problem was (I think) that I was initializing a member array in the declaration instead of in the constructor. The error was that the the VisualStudio project for my application immediately crashed when I tried to use the custom control from my lib that had the "bad" declaration.
It was frustrating because my custom component lib compiled with no errors.
Brooke
code that crashed:
solution
I have come across this problem as well. I Have one project(ProjA) that contains user controls and another project(ProjB) that references those user controls. I found that every time I attempt to add a particular user control the vb.net Environment shuts down and reloads my solution. However, if I comment out the code that's contained within my controls LOAD event
and then rebuild my solution, I run into no problems when adding this control to a form. It's very strange that this problem occurs in only one control when I have 7 other controls in the same project that all function in the same manner with no errors.
Personally, I think VB.NET hates me.
I solved my crashing designer using techniques described here:
Good Way to Debug Visual Studio Designer Errors
AND
It seems that the Load() method of UserControls somehow gets parsed by the designer. Putting initialisations and other suspicious code in a if - loop - checking for IsDesignMode keeps the designer from reading code that will crash it ....
--update: looking back now, all most things solved when I overthought / refactored the application design.