locked
Unit Test Generation Error RRS feed

  • Question

  • For some reason I'm getting an exception in VS 2010 when I try and do a "Create Unit Test" from a class I've defined.  Once I right click on the class in the code and select "Create Unit Tests", I immediately get the following exception:

    Unit Test Generation Error: The following error was encountered while reading module "blah.blah.blah.Common": Could not resolve type reference:[System, Version=2.0.00, Culture=neutral, PublicKeyToken="blah"]System.Collections.ObjectModel.ObservableCollection ' 1

    Any ideas?

    Monday, June 28, 2010 8:11 PM

Answers

  • Hello,

    What is the edition of VS2010 are you working with? Office release or beta? It is suggest you work with the office release one. You can get a trial one from here:

    You could also try the following steps to see if this issue still exists:

    a)     Try to run devenv /ResetSettings (in command prompt) to eliminate the related potential settings problem.

    b)     Try disabling Add-ins (e.g. “Tools” | “Add-in Manager”) or run “devenv.exe /SafeMode”.This can eliminate the possibility that third party Add-ins or packages are causing problems. (For more detailed VS command line switches information, see: http://msdn2.microsoft.com/en-us/library/xee0c8y7.aspx )

    c)     Try creating a new project. Sometimes corrupted project settings can cause problems. These are project specific.

    d)     Try to reboot the operating system to safe mode. This can help to isolate whether any other applications are interfering with Visual Studio. Note that some features (like IIS) are not available under safe mode. Please check whether this can be applied or not. In addition to safe mode, we can also try “clean boot”: How to configure Windows XP to start in a "clean boot" state http://support.microsoft.com/kb/310353 .

    e)      Try to create a new user account. This can help isolate user profile corruption related causes.

    Also try running 'devenv /setup and devenv /resetskippkgs' in order with command prompt.


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Tuesday, June 29, 2010 8:25 AM
    Moderator
  • I experienced a similar issue.  After converting a VS 2008 project that was on framework 2.0 to a VS 2010 project on framework 3.5, the project generated a "BuildShadowTask task failed unexpectedly" error during the build.  So I dropped the test project from the solution.  The build succeeded.  Then I went to a class and right clicked and selected "Create Unit Tests...".  The "Create Unit Tests" dialog appeared and on top of it was an error message:

    "Unit Test Generation Error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". 

    Clicking Ok closed the error and dialog with no tests being generated. 

    Regarding your suggestions:

    a) I ran devenv /ResetSettings from the command prompt.  It started Visual Studio.  I opened my project.  The error still ocurrs.

    b) I don't have any Add-Ins installed, but I had one extension.  I disabled this and restarted Visual Studio.  The error still ocurrs.  Interestingly, when I reenabled it and restarted the project, the error did not occur when the dialog opened, but as soon as I clicked the checkbox for the first (only) item in the list, it occurred.  I could not reproduce this and now the error occurs as before.

    c) The error does not occur on a new project.  What does it mean if my project settings are corrupted?  How can I fix that?

    d) I will try these when I have time to restart my system

    e) In my coorporate environment I do not have permission to create new user profiles.

    I ran 'devenv /setup and devenv /resetskippkgs' in order with command prompt, and the error still occurs. 

    Another thing, during all of these restarts of VS, about half the time while closing it generates a "Microsoft Visual Studio has encountered a problem and needs to close." error.  I also receive an "Installing Office Customization: There was an error during installation" message whenever I start Excel 2007.  This has been happing since the VS 2010 installation.  So there may deeper issues with my VS installation.

    I'm running Windows XP Pro SP3.

    Thanks in advance.

    Friday, July 2, 2010 7:06 PM

All replies

  • Hello,

    What is the edition of VS2010 are you working with? Office release or beta? It is suggest you work with the office release one. You can get a trial one from here:

    You could also try the following steps to see if this issue still exists:

    a)     Try to run devenv /ResetSettings (in command prompt) to eliminate the related potential settings problem.

    b)     Try disabling Add-ins (e.g. “Tools” | “Add-in Manager”) or run “devenv.exe /SafeMode”.This can eliminate the possibility that third party Add-ins or packages are causing problems. (For more detailed VS command line switches information, see: http://msdn2.microsoft.com/en-us/library/xee0c8y7.aspx )

    c)     Try creating a new project. Sometimes corrupted project settings can cause problems. These are project specific.

    d)     Try to reboot the operating system to safe mode. This can help to isolate whether any other applications are interfering with Visual Studio. Note that some features (like IIS) are not available under safe mode. Please check whether this can be applied or not. In addition to safe mode, we can also try “clean boot”: How to configure Windows XP to start in a "clean boot" state http://support.microsoft.com/kb/310353 .

    e)      Try to create a new user account. This can help isolate user profile corruption related causes.

    Also try running 'devenv /setup and devenv /resetskippkgs' in order with command prompt.


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Tuesday, June 29, 2010 8:25 AM
    Moderator
  • I experienced a similar issue.  After converting a VS 2008 project that was on framework 2.0 to a VS 2010 project on framework 3.5, the project generated a "BuildShadowTask task failed unexpectedly" error during the build.  So I dropped the test project from the solution.  The build succeeded.  Then I went to a class and right clicked and selected "Create Unit Tests...".  The "Create Unit Tests" dialog appeared and on top of it was an error message:

    "Unit Test Generation Error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". 

    Clicking Ok closed the error and dialog with no tests being generated. 

    Regarding your suggestions:

    a) I ran devenv /ResetSettings from the command prompt.  It started Visual Studio.  I opened my project.  The error still ocurrs.

    b) I don't have any Add-Ins installed, but I had one extension.  I disabled this and restarted Visual Studio.  The error still ocurrs.  Interestingly, when I reenabled it and restarted the project, the error did not occur when the dialog opened, but as soon as I clicked the checkbox for the first (only) item in the list, it occurred.  I could not reproduce this and now the error occurs as before.

    c) The error does not occur on a new project.  What does it mean if my project settings are corrupted?  How can I fix that?

    d) I will try these when I have time to restart my system

    e) In my coorporate environment I do not have permission to create new user profiles.

    I ran 'devenv /setup and devenv /resetskippkgs' in order with command prompt, and the error still occurs. 

    Another thing, during all of these restarts of VS, about half the time while closing it generates a "Microsoft Visual Studio has encountered a problem and needs to close." error.  I also receive an "Installing Office Customization: There was an error during installation" message whenever I start Excel 2007.  This has been happing since the VS 2010 installation.  So there may deeper issues with my VS installation.

    I'm running Windows XP Pro SP3.

    Thanks in advance.

    Friday, July 2, 2010 7:06 PM
  • Hello,

    I will mark the reply as answer, if you find it no help, you can feel free to unmark it.


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Wednesday, July 7, 2010 7:34 AM
    Moderator
  • So I'm still confused as to what I am supposed to do with my converted project.  If the project settings are corrupted, is there any way to fix them?  Or is my only solution to created a new project and import all my code?
    Wednesday, July 7, 2010 8:53 PM
  • I am experiencing a similar issue - although in my case, some projects allow unit tests to be created while others give me the error noted at the beginning of this thread.  All of the suggestions marked in the "Answer" do not work; I'm still getting the error.  Creating a new project works but only for that project; all the other existing projects that were experiencing this error are still experiencing this error.  Are there any other solutions or updates to this problem?  Thx!
    Monday, July 12, 2010 8:02 PM
  • I have the same problem.. when i try to create a unit test in web site solution...

    Any solution?


    http://marcoscavaleiro.blogspot.com
    Monday, September 20, 2010 12:50 PM
  • I tried the above and various reinstalls etc. The problem repeated itself so the resolution was to recreate the solution. Drag all the projects associated with it and volla. There was no problem defining the tests and the error did not appear. I take it that there is a bug when migration from previous versions of the solution file to the VS10 version.

    Having done that everything works smoothly.

    • Proposed as answer by cuipengfei Monday, November 21, 2011 2:37 AM
    Thursday, March 3, 2011 12:11 PM
  • Hello,

    I have a similar error (with BlahBlahBlah.Common = WindowsBase) an try to run devenv /ResetSettings (in command prompt) to eliminate the related potential settings problem.
    Nothing changes. I have no add-ins in my add-in-manager. I use the release-version of Visual Studio Professional 2010.

    I create a new project, copy the code of the class, which I want to test, generate a unittest and it works. I copy the unittest to the first projekt and it works too.

    For the next unittest I try the same, but I have to many dependencies, so that I have to work 1-3 hours to get the new project to work.

    So that is not really a solution.

    Unittests should make the work easier. There is no time for days searching, which other applications are interfering with Visual Studio.

    Please fix the bug.

    Thanks

    Peter

     

     

     

    • Proposed as answer by cuipengfei Monday, November 21, 2011 2:38 AM
    Thursday, March 17, 2011 1:43 PM
  • I had the exact same problem.

    My project was a conversion from VS 2005 to VS 2010.

    I started a new test project and everything worked fine.

    My final solution:

    1. Delete the sln and suo files.
    2. Start VS 2010
    3. Navigate "File" / "Open" / "Web Site", then select the root folder of your web site.
    4. After the project opens, Navigate "File" ? "Save All"
    5. Enter the name of your solution file and navigate to the folder where you want it kept.

    You should be able to use the feature now.

    I compared the old and new sln files.

    The old/new ProjectSection sections had very minor differences (and none that should logically cause the problem). The PreSolution and PostSolution sections were considerably different, But again, nothing that looked obvious.

    The big difference is that the old SLN file was converted and the new one was created by VS 2010 new.\\

    If anyone cares to investigate the matter any deeper, please post your findings here.

    Thanks,

    Rog.

    • Proposed as answer by cuipengfei Monday, November 21, 2011 1:28 AM
    Tuesday, July 26, 2011 12:41 PM
  • I am experiencing an error when I try to create unit test in Visual studio 2010 ultimate for my web appication project. It is a migrated application.

    I have a some class file in my project. I want to test one of my functions in a class file. When I right click on method and select Create Unit Tests, it pops up an error that says.

    Unit Test Generation Error. It is an error to use a section registered as allowDefinition

    ='MachineToAppication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

    But I have already configured virtual directory of this appication in IIS. It is IIS 7.5

    Sometimes I get another one that says

    Unit Test Generation Error. Could not find a part of the path c"\Users\babybe\AppData\Temp\tmp7E90........compiled.

    My application is under another path and its virtual path is configured in IIS.

    Anybody can help me?

    Thanks

    Ben

    Saturday, November 5, 2011 5:19 AM
  • I experienced the same issue.

    It was because I had a reference to another project and it was deployed and included in the GAC. I've just resolved uninstalling the assembly from the GAC.

    Tuesday, December 11, 2012 5:23 PM