0

I'm creating a website using MVC (Visual Studio) and I get error "spawn unknown" when I debug using IIS Express. What is causing this error and how can I resolve it?

This is using Visual Studio 2017, but I suspect it could be something to do with the way it's configured on my computer, since this error doesn't occur on other computers.

This is the view:

@model WebApplication4.Models.Customer

@{
    ViewBag.Title = "Index";
}
<h2>Index</h2>

And the controller:

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);
        }
}

And the model:

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
    };
}

When I debug the solution with IIS Express, instead of opening Chrome and displaying the index page, I get a pop-up box from Microsoft Visual Studio, saying: One or more errors occurred. [debugger-for-chrome] Error processing "launch":spawn UNKNOWN

There are numerous questions on "spawn unknown" but none concerning C# or MVC (generally node.js or php - there is a question about the error in VS here but it's about a pop-up that appears after opening .php extension files. According to this answer: Error: spawn UNKNOWN it looks like the issue is to do with using Chrome as the web browser. However is it possible to change IIS Express to use something other than Chrome?

half of a glazier
  • 1,864
  • 2
  • 15
  • 45

2 Answers2

2

It looks like the problem is when trying to debug a program from Visual Studio to Chrome with different privileges. When both VS and Chrome are run with admin privileges (or both as normal) the error doesn't show up.

half of a glazier
  • 1,864
  • 2
  • 15
  • 45
1

For me, it was not privilege issue. The issue was that in my computer Chrome was installed at two different places:

C:\Users\[user]\AppData\Local\Google\Chrome\Application\chrome.exe
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

For my PC, the first one is broken executable, it's 64 bit one and somehow it've turned out to trash that doesn't work anymore, so I somehow managed to reinstall Chrome 32 bit onto the second path. Anyway, ended up to the state two Chrome executable coexists.

I totally forgot there is another one, and also in the PATH the second one is being added, so I didn't think the possibility VS code refers the one.

So in such case, you need to provide runtimeExecutable in your launch.json, like this:

{
    "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",
        }
    ]
}
ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33