Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch kestrel-based console app #789

Closed
aggieben opened this issue Sep 28, 2016 · 9 comments
Closed

Unable to launch kestrel-based console app #789

aggieben opened this issue Sep 28, 2016 · 9 comments

Comments

@aggieben
Copy link

aggieben commented Sep 28, 2016

Environment data

dotnet --info output:

 [master ↑ +8 ~8 -1 !]
λ dotnet --info
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version:
C# Extension version: 1.4.1

Steps to reproduce

Build kestrel app with a Main that looks like this:

        var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseKestrel()
                .UseConfiguration(config)
                .UseStartup<Startup>()
                .Build();

            host.Run();

Then after opening the project in VsCode and the extension goes through it's first-time setup, try to launch the app with F5 or the launcher.

Expected behavior

My app running with symbols loaded in the debugger.

Actual behavior

A break on this:
image

After I click the button to continue, the following error appears in the console:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Server.Kestrel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at MyNamespace.Web.Program.Main(String[] args)

and then the process exits.

I tried referencing Kestrel explicitly in my project.json (version 1.0.*), but that didn't change anything.

@gregg-miskelly
Copy link
Contributor

@aggieben this doesn't sound like an issue with the C# extension - it sounds like building your app isn't setting up the output directory such that your app actually runs.

What template are you starting your app from?

@aggieben
Copy link
Author

I started with dotnet new, I think. What do you mean about the output directory? I don't think I've done anything to affect that.

@gregg-miskelly
Copy link
Contributor

dotnet new or dotnet new -t web?
Do you have a dependency on Microsoft.AspNetCore.Server.Kestrel in your project.json? If so, did you do a dotnet restore after adding it?

Your app is crashing because it can't find Microsoft.AspNetCore.Server.Kestrel.dll. I am not a super expert on assembly resolution, but from my understanding there are two places where the runtime might go to try and find the assembly - next to the app itself, or in the 'shared framework' directory.

@aggieben
Copy link
Author

aggieben commented Sep 29, 2016

Ah, just was able to get back to my desk and definitely I used dotnet new as a console app.

Here's my project.json:

    "version": "1.0.0-*",
    "buildOptions": {
        "debugType": "portable",
        "preserveCompilationContext": true,
        "emitEntryPoint": true
    },
    "dependencies": {
        "Microsoft.AspNetCore.Http.Abstractions": "1.0.*",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.*",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.*",
        "Microsoft.Extensions.DependencyInjection": "1.0.*",
        "Microsoft.EntityFrameworkCore": "1.0.*",
        "Microsoft.EntityFrameworkCore.Design": {
            "version": "1.0.0-*",
            "type": "build"
        },
        "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.*",
        "Npgsql.EntityFrameworkCore.PostgreSQL.Design": {
            "version": "1.0.*",
            "type": "build"
        },
        "MyNamespace.Extensions": {
            "target": "project"
        }
    },
    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-*"
    },
    "frameworks": {
        "netcoreapp1.0": {
            "dependencies": {
                "Microsoft.NETCore.App": {
                    "version": "1.0.*",
                    "type": "platform"
                }
            }
        }
    }
}

The way I've been testing my app is simply to do dotnet run on the console and look at log output.

@aggieben
Copy link
Author

aggieben commented Oct 17, 2016

Just to be clear, this is still broken for me. I can run my application on the console with dotnet run (as long as I delete obj and bin first). I have since updated my SDK to 1.0.0-preview2-0023131. Code still fails, although now it fails on

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
   at Cm.Core.Program.Main(String[] args)

I am at a bit of a loss and would like to be able to use the debugger but currently can't.

@DustinCampbell
Copy link
Member

Is this still an issue? Note, the problem is likely not an issue with C# for Visual Studio.

@DustinCampbell
Copy link
Member

If you're still able to reproduce the problem, could you provide a copy of a project that exhibits this behavior? I tried to cobble together something from the information that you provided above, but had to tweak enough to get it to compile that I'm not confident my final project is similar to what you have. However, even then, I wasn't able to reproduce. If you have something you can provide that reproduces the issue, please let us know.

@aggieben
Copy link
Author

I think somewhere along the way an update to the tooling resolved it; I'm not experiencing this issue anymore.

@DustinCampbell
Copy link
Member

Glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants