[英]Could not load file or assembly 'System.Web.Mvc In Unit Test
I have unit tests and inside them I call a method that eventually calls this line: 我有单元测试,在其中,我调用了一个最终调用此行的方法:
DataSourceResult response = lstshiftGroup.ToDataSourceResult(request);
Which throws this exception: 引发此异常:
Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
无法加载文件或程序集'System.Web.Mvc,版本= 3.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 The system cannot find the file specified.
该系统找不到指定的文件。
In my test project I have reference of System.Web.Mvc, Version=4.0.0.0 and in my project I have the same assembly. 在我的测试项目中,我引用了System.Web.Mvc,版本= 4.0.0.0,在我的项目中,我具有相同的程序集。
What is wrong with my test? 我的考试出了什么问题?
You need to add reference to Asp.Net MVC to your Unit Test project. 您需要在单元测试项目中添加对Asp.Net MVC的引用。 You can do this with NuGet.
您可以使用NuGet做到这一点。 Here is the link to NuGet for MVC.
这是指向NuGet for MVC的链接。 Follow the instructions there to install it into your Unit Test project: https://www.nuget.org/packages/aspnetmvc
按照那里的说明将其安装到单元测试项目中: https : //www.nuget.org/packages/aspnetmvc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.