Aspnet MVC 2 starter project compilation error

When starting your first Aspnet MVC2 project you might immediately run into compilation errors like these:

Error 1 The type or namespace name ‘Controllers’ does not exist in the namespace ‘MvcApplication1’ (are you missing an assembly reference?) C:\myprojectpath\MvcApplication1.Tests\Controllers\HomeControllerTest.cs 8 23 MvcApplication1.TestsError 3 The type or namespace name ‘Models’ does not exist in the namespace ‘MvcApplication1’ (are you missing an assembly reference?) C:\myprojectpath\MvcApplication1.Tests\Controllers\AccountControllerTest.cs 10 23 MvcApplication1.Tests

Error 4 The type or namespace name ‘AccountController’ could not be found (are you missing a using directive or an assembly reference?) C:\myprojectpath\MvcApplication1.Tests\Controllers\AccountControllerTest.cs 317 24 MvcApplication1.Tests

The origin of the problem is that the test project doesn’t reference the web project. Just add the reference and you’re good to go.

I haven’t found the solution on google yet so I write this here to someones possible future aid.

3 Responses to “Aspnet MVC 2 starter project compilation error”

  1. Anonymous says:

    >This was indeed helpful, thank you!

  2. Anonymous says:

    >Very much appreciated. Thank You!

  3. stupidGeek says:

    I had the same problem, too. However, I looked at here and was settled.
    http://www.eggheadcafe.com/community/aspnet/17/10175256/aspnet-mvc.aspx

    I tried to Add Reference Main project for xxx.Tests projects References.
    I can compile it in this smoothly.
    But I cannot think this to be the radical solution.

Leave a Reply