开发者

Visual Studio 2010 crashes when opening a form, containing an user control, in design mode

Following is my problem: I have a custom UserControl in my Windows Forms Project. I can design it in the designer just fine. But as soon as i want to edit the form which contains the control Visual Studio 2010 crashes.

As far as i could see the Constructor and the Load-Event of the control are executed on loading the form.

I tried using another instance of VS2010 to debug the designer, but could not find the location where the execption occurs.

At first my problem seemed to be, that for the Threading.Timer object, which i use for the initialisation of my Objects (i.e. Loading values from a Database and so on (on error try again later approach ;))), the Callback-Function was executed by the designer an therefore it attempte开发者_开发百科d to access objects to which it had no access while in the design mode. The initialisation of the Threading.Timer Object is in the Load-Event. But even after i commented everything in the load event out (except a try catch block an a Debugger.Break() Call for having a breakpoint in the second instance VS2010 to debug the designer) Visual Studio keeps crashing as soon as I want to edit the form containing the control in design mode.

I tried some steps I found here without an answer to my problem: User control always crashes Visual Studio

So even if the designer has nothing to do when parsing the Load-Event or the Constructor. It still crashes.

Has someone an idea what I could do to prevent Visual Studio from crashing and displaying the user control properly in the forms designer?

The project containing the usercontrol also references some custom libraries and a library project. I don't know if the problem could have something to do with that.


Solved somehow my own problem...

Somehow by trying to debug the designer mode i tricked myself.

Setting a Debugger.Break() in the Load-Event was a very bad idea while trying to open the form containing the user control in the designer mode, because if you are not debugging Visual Studio with another instance of Visual Studio then Debugger.Break() will stop the Application and therefore crashes the Visual Studio Instance.

In the end by Using the DesignerMode Property of the User Control I was able to prevent the designer from executing the initialisation of my threading.Timer Objects could solve the problem this way.


I had this same issue(VS 2005), and the marked answer also didn't work for me. I was finally able to solve the issue by deleting the "obj" and "bin" folders in my solution and then rebuilding the project in release mode. I hope this helps anybody else who is having this issue.


In my problem, the whole solution crashed every time I opened it due to design mode opening the guilty file every time I opened the solution and thus causing the whole solution to crash, it could have been caused by user controls but I couldn't access the solution to resolve.

So I found an alternative way to just allow me to get back to my coding.. It didn't involve getting really deep into debugging system events, I think it can help all levels of user, hence posting.

I opened the aspx file outside of the solution, literally just the frontend code file, could be done in Notepad or any text editor including VS. Commented out all the code (java code didn't matter as nothing is calling it) Saved the file and closed. Reopened the solution. Even though the designer view opened, this time it didn't crash as there was nothing to process. I then uncommented the code in sections, various amounts of code, 20 lines, 100 lines... each time going back into the designer view to check if it would crash. When I'd completed (no crashes!) I was able to continue from where I'd left off. Hope it helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜