google-chrome - 将 Visual Studio MVC 应用程序调试到 Chrome 时出现“spawn UNKNOWN”错误
问题描述
我正在使用 MVC (Visual Studio) 创建一个网站,当我使用 IIS Express 进行调试时出现错误“spawn unknown”。是什么导致了这个错误,我该如何解决?
这是使用 Visual Studio 2017,但我怀疑这可能与它在我的计算机上的配置方式有关,因为此错误不会在其他计算机上发生。
这是视图:
@model WebApplication4.Models.Customer
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
和控制器:
namespace WebApplication4.Controllers
{
public class CustomerController : Controller
{
private ApplicationDbContext _context;
public CustomerController()
{
_context = new ApplicationDbContext();
}
// GET: Customer
public ActionResult Index(int id)
{
var customers = _context.Customers.ToList();
return View(customers);
}
}
和模型:
namespace WebApplication4.Models
{
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public Membership MembershipType { get; set; }
}
public enum Membership
{
REGULAR,
SILVER,
GOLD
};
}
当我使用 IIS Express 调试解决方案时,我没有打开 Chrome 并显示索引页面,而是从 Microsoft Visual Studio 中得到一个弹出框,提示:发生了一个或多个错误。[debugger-for-chrome] 处理“启动”时出错:spawn UNKNOWN
关于“spawn unknown”有很多问题,但没有关于 C# 或 MVC(通常是 node.js 或 php -这里有一个关于 VS 错误的问题,但它是关于打开 .php 扩展文件后出现的弹出窗口。根据到这个答案:错误:产生未知它看起来问题与使用 Chrome 作为网络浏览器有关。但是是否可以将 IIS Express 更改为使用 Chrome 以外的其他东西?
解决方案
对我来说,这不是特权问题。问题是在我的计算机中,Chrome 安装在两个不同的位置:
C:\Users\[user]\AppData\Local\Google\Chrome\Application\chrome.exe
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
对于我的 PC,第一个是损坏的可执行文件,它是 64 位的,不知何故它变成了垃圾,不再起作用,所以我设法将 Chrome 32 位重新安装到第二个路径上。无论如何,最终导致两个 Chrome 可执行文件并存。
我完全忘记了还有另一个,并且在 PATH 中添加了第二个,所以我认为 VS 代码没有引用这个的可能性。
因此,在这种情况下,您需要runtimeExecutable
在您的 launch.json 中提供,如下所示:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "https://example.com",
"runtimeArgs": ["--load-extension=${workspaceFolder}"],
"runtimeExecutable": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
}
]
}
推荐阅读
- flutter - 颤动的网络数据表滚动 - 可怕的性能
- java - 程序生成产生错误信息
- php - PHP从数组内的数组形成自定义数组
- python - Python集:用奇数填充
- ios - Swizzling UIImage init 不工作 iOS Swift
- sql - sql查询'IN'操作符不工作错误?
- android - 应用程序已停止使用 Android Studio 工作,代码中未检测到错误
- c# - 如何使用 webhook 在 SharePoint 网站上获取更改?
- polymer - 如何将旧版本的 LitElement 转换为新版本
- django - django模型中的条件选择字段