Missing reference to System.Web.Mvc in Asp.net Unit Test?

前端 未结 2 1184
隐瞒了意图╮
隐瞒了意图╮ 2021-02-18 23:09

I recently made some unit tests for my Asp.NET MVC application, or I tried to, it keep telling me \"The type \'System.Web.Mvc.Controller\' is defined in an assembly that is not

相关标签:
2条回答
  • 2021-02-18 23:15

    MVC 5 comes in from a NuGet package. Just as it did with the main MVC web project in your solution. Install MVC via NuGet into your Test project, and you should be good to go.

    0 讨论(0)
  • 2021-02-18 23:21

    An educated guess, but you might have obtained the newer version via a nuget package(some of the newer MVC project templates do this), and thus it is not installed in GAC. Use the nuget package manager for the MVC project to determine if this is the case, and if so then mystery solved.

    In the test project you can add the same package, or use the addreference->Browse to browse into the nuget dependencies and poke around under the MVC project till you find the DLL(it will be in the file system somewhere under SolutionName/MvcProjectName/packages).

    0 讨论(0)
提交回复
热议问题