Create 2 portable class libraries projects in the first (Models) folder.
Create a UnitTest project in the second (Unit.Tests) folder.
Try out the generate type by usage feature, selecting "Generate new type...", within a TestMethod in the UnitTest project.
Select the second portable class library project for where to place the file.
I get a error message. "Generate Type failed. Object reference not set to an instance of an object."
Unload the first project. Try again. This time it works. Reload first project, and it doesn't work again.
Solutions? I'm trying to get some work done.
The "Generate New Type" dialog sure could use some improvements. I have to copy the file name it suggests before selecting a different project then folder within that project, then paste the name back in. This slows down my productivity. (yeah, maybe I'm just nip-picking just a bit ).
Maybe I should just select the defaults and move the files afterwards to the proper project, and fix up the name space, and add in the reference to the project all manually instead.
This bug is present in VS2010, as I loaded the VS2012 project as described above, created a new unit test project, as the 2012 version is not compatible, and same error.
Note that I can add a type to an existing file in any project, without error.
Update: the error happens even if you create the unit.test project in the same folder as the other projects.
Using C Sharp for all projects.
I suspect that the "Object reference not set to an instance of an object" message is thown by your first project as this function runs fine here. Perheps your first project use some late binding types from Type.GetTypeFromProgId() or Type.GetTypeFromCLSID() ?
If you follow the steps I outlined and create a brand new solution, with no classes yet in the projects except for the test project, the error message will still occur. I will double check though.
Or, create 3 class library projects. Error still occurs.
I have two persistent bugs in VS2012
if the startup project is config manager platform "any cpu", when starting in debug mode I get a "remote endpoint was unreachable" error. I get that error sometimes. The fix is to change the platform from the any cpu default to x86.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.