views:

507

answers:

3

I have solution that builds without errors or warnings. I created a class diagram in VS 2008 that shows one of my classes. I then right clicked on the class and choose create instance, and the it's parameter less constructor. I provide name for the new instance and then click OK.

It then just shows an "Object Test Bench" error "Create Instance Failed", and in the details in only shows "0x80004005".

Anyone have any idea what is going on?

Update

I figured it out. The project is a plugin for another program so if I go to the debug tab of the project settings the "Start Action" is set to run that program. When I changed that to "Start Project" and ensured the "Enable the Visual Studio hosting process" was check it worked".

Update 2

Ok just kidding, still doesn't work. Now I don't get the error for the first object, but the Object Test bench window never opens. At that point if I try to create any other instance by right clicking on any class in the class diagram the constructor method for any class is checked on the menu and it doesn't do anything if I click it. If I close visual studio I get another "Create Instance Failed" box but this time the details portion says "An expression evaluation is already in progress."

A: 

I recognize that as a database connection error.

RedFilter
A: 

So are you saying that visual studio crashes, or your app crashes?

If its visual studio then the normal advice applies: reinstall it. Having said that, try everything else you can think of first, because its a bit of a painful last resort.

Also, look in your event viewer: Start->Run->eventvwr->Application and see if you can find this error, then post the details. By the sounds of it, its a visual studio error because errors in your c# app should throw exceptions rather than ugly hex error codes.

Chris
Nothing really crashes. The error window pops up that says it can't create an instance I just click OK and it goes back to visual studio.
Eric Anastas
A: 

That is indeed a database error. One can reproduce the error in the NerdDinner example MVC app:

  1. Generate a new Class Diagram
  2. Drag the Dinner model class onto it
  3. Then right-click >> create instance >> parameter-less constructor Dinner()

I believe this error is happening because the class silently depends on things like a connection string in web.config and other things intrinsic to the the web host, which don't exist at design-time in the Class Diagram tool.

Are you trying to use the Class Diagram tool on a Web Application project? It appears Microsoft is dead-ending the Object Test Bench due to lack of interest: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=423741

Kelly Adams