VS2017 xUnit IActionResult,Controller在未引用的程序集中定义。无法找到ViewResult。 [英] VS2017 xUnit IActionResult, Controller defined in an assembly that is not referenced. ViewResult could not be found.

查看:302
本文介绍了VS2017 xUnit IActionResult,Controller在未引用的程序集中定义。无法找到ViewResult。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2017 xUnit IActionResult,在未引用的程序集中定义的Controller。找不到ViewResult。



书中:Pro ASP.NET Core MVC,第7章,单元测试MVC应用程序。


我正在寻找要安装的Nuget软件包来安装这些错误。对这些项执行Install-Package时,引用上会出现带有黄色警告三角形的NuGet依赖项。


错误 CS0012
类型'IActionResult'在未引用的程序集中定义。您必须添加对程序集'Microsoft.AspNetCore.Mvc.Abstractions,Version = 1.1.2.0, 


的引用。类型'Controller'在未引用的程序集中定义。您必须添加对程序集'Microsoft.AspNetCore.Mvc.ViewFeatures,Version = 1.1.2.0 


的引用无法找到类型或命名空间名称'ViewResult'(您是否遗漏了) using指令或汇编引用?)



依赖关系,NuGet:

Microsoft.NET.Test.Sdk,15.0.0

xunit 2.2.0

xunit.runner.visualstudio 2.2.0



SDK

Microsoft.NETCore.App




解决方案

>>类型'IActionResult'是在未引用的程序集中定义的。您必须添加对程序集'Microsoft.AspNetCore.Mvc.Abstractions,Version = 1.1.2.0,


>>类型'Controller'的引用在未引用的程序集中定义。您必须添加对程序集'Microsoft.AspNetCore.Mvc.ViewFeatures,Version = 1.1.2.0


的引用。根据这两个错误,请确保您已添加这两个错误项目中的命名空间,包含IActionRestult和Controller类型。


>>找不到类型或命名空间名称'ViewResult'(您是否缺少using指令)或汇编引用?)


此错误表示没有包含ViewResult命名空间的dll文件,因此请确保添加了包含ViewResult命名空间的dll。 / p>

如果可能,请将您的项目分享给我,您可以将其上传到OneDrive并在此处以
文字格式分享链接。


此致,


奥斯卡


Visual Studio 2017 xUnit IActionResult, Controller defined in an assembly that is not referenced. ViewResult could not be found.

From book: Pro ASP.NET Core MVC, Chapter 7, Unit Testing MVC Applications.

I am looking for Nuget packages to install that will install these errors. When performing Install-Package on these items, a NuGet dependency with a yellow warning triangle appears on the reference.

Error CS0012 The type 'IActionResult' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.Abstractions, Version=1.1.2.0, 

The type 'Controller' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=1.1.2.0 

The type or namespace name 'ViewResult' could not be found (are you missing a using directive or an assembly reference?)

Dependencies, NuGet:
Microsoft.NET.Test.Sdk, 15.0.0
xunit 2.2.0
xunit.runner.visualstudio 2.2.0

SDK
Microsoft.NETCore.App


解决方案

Hi David R. Stevenson,

>>The type 'IActionResult' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.Abstractions, Version=1.1.2.0,

>>The type 'Controller' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=1.1.2.0

According to the two errors, please make sure you have added these two namespaces in your project, which contains IActionRestult and Controller type.

>>The type or namespace name 'ViewResult' could not be found (are you missing a using directive or an assembly reference?)

This error means there is no dll file that contains ViewResult namespace, so please make sure that you have added a dll that contains ViewResult namespace.

If possible, please share me your project, you could upload it to OneDrive and share a link here in text format.

Sincerely,

Oscar


这篇关于VS2017 xUnit IActionResult,Controller在未引用的程序集中定义。无法找到ViewResult。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆