views:

231

answers:

5

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.

A: 

Try to comment out parts or even the complete constructor of the control and see if it shows up. Maybe it is another initialization that fails, too.

tanascius
Commenting out everything in the constructor didn't prevent it from crashing. Thanks for the suggestion, though!
NickAldwin
+1  A: 

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.

Hans Passant
+1 for debugging with another instance of VS, that works for me.
Chris O
I tried debugging with another instance of VS, but it doesn't seem to be reaching my code at all! If I break all, it's either in a "wait" or says no symbols are loaded for any call stack frame...
NickAldwin
A: 

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!

KMan
A: 

I've had some similar problems when creating my own user controls in Visual Studio, but have been able to get the user controls to display properly by following these steps:

  1. Build or rebuild the project / solution
  2. Close Visual Studio and reopen it

These are pretty basic things that I bet you've already tried. Just throwing it out there.

Jon
A: 

Your user control may have a property written like this:

private int myPropName; // note the lowercase m
public int MyPropName { get { return MyPropName; } } // the property is returned
                                                     // instead of the variable

Note that the value returned by get is the property itself. This crashes VStudio 2008 when trying to see the properties of the control, which also happens when adding the control (by drag'n drop or else) to a Form.

As pointed out by NickAldwin, this does not generate compiler warning or error.

Gabriel
But this should also cause compiler errors/warnings, which I am not getting.
NickAldwin
Nope, no compiler warning/error !
Gabriel