locked
Error when Creating Unit Tests RRS feed

  • Question

  • I am new to testing in Visual Studio. I have Visual Studio Professional 2010 (not Team). I just want to be able to create some basic tests to verify that the methods I've created are producing the right output given specific parameter values.

    However, when I open the class that contains the methods I want to test and right-click and select Create Unit Tests, it pops up an error that says.

    Unit Test Generation Error: The following error was encountered while reading module 'System.Web.Entity': Could not resolve type reference: [System, Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]System.Web.UI.WebControls.IQueryableDataSource.

    However, I can't find a reference to that version of the System.Web.Entity dll. I do have a reference to the v4.0.30319 version. This was originally a .NET 3.5 project, but has since been upgraded to .NET 4.0 project. In order to try to fix this error, I created a new .NET 4.0 web application from scratch and pasted all my code and files into it, but that didn't help.

    Can anyone tell me where to find this old reference to the 3.5 version of System.Web.Entity so I can get rid of it and create my tests?


    Nathon Dalton
    Software Developer
    Systems Administrator
    Network Administrator
    Blog: http://nathondalton.wordpress.com
    Friday, September 17, 2010 5:57 PM

Answers

  • Hi Nathon

    I had a similar error and solved it by making sure the assemblies of other projects I was referencing were also running on .NET 4.0.

    Then did a clean and rebuild and it worked.

    hth

    Nico

    • Marked as answer by Nathon Dalton Thursday, September 23, 2010 10:02 PM
    Thursday, September 23, 2010 12:40 PM

All replies

  • Hi Nathon

    I had a similar error and solved it by making sure the assemblies of other projects I was referencing were also running on .NET 4.0.

    Then did a clean and rebuild and it worked.

    hth

    Nico

    • Marked as answer by Nathon Dalton Thursday, September 23, 2010 10:02 PM
    Thursday, September 23, 2010 12:40 PM
  • Ahhhhhh.... Now that makes perfect sense! See I also have a SQL Database project in this solution and those are restricted to .NET Framework 2.0.

    So, I guess that means I have to make a decision. Either I want to be able to run tests against my project or I want the database project to be part of the solution. I guess I could also temporarily remove the database project from the solution, run tests and then re-add it when I'm done... but that's a pain in the neck every time I want to build the project.

    Anyway, thank you very much for the answer!


    Nathon Dalton
    Software Developer
    Systems Administrator
    Network Administrator
    Blog: http://nathondalton.wordpress.com
    Thursday, September 23, 2010 10:02 PM