question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MissingMethodException when running NSwag run on ASP.NET Core on net47

See original GitHub issue

I’ve been trying to get NSwag to generate a typescript file for an ASP.NET Core application for the net47 target. This by using the aspnetcore2swagger generator and by giving it a csproj file (as apposed to an assembly).

Version info:

  • .NET: net47
  • asp.net core: 2.1.3
  • nswag: 11.19.1

When running dotnet build, I get the following error:

dotnet build
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 41.12 ms for D:\proj\nswagnetfull.csproj.
  nswagnetfull -> D:\proj\bin\Debug\net47\nswagnetfull.exe
  nswagnetfull -> D:\proj\bin\Debug\net47\nswagnetfull.Views.dll
  NSwag command line tool for .NET 4.6.1+ WinX64, toolchain v11.19.1.0 (NJsonSchema v9.10.72.0 (Newtonsoft.Json v9.0.0.0))
  Visit http://NSwag.org for more information.
  NSwag bin directory: C:\Users\bob\.nuget\packages\nswag.msbuild\11.19.1\tools\Win

  Executing file 'nswag.json'...
  Launcher directory: D:\proj\bin\Debug\net47
  System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.Hosting.Server.IServer.Start(Microsoft.AspNetCore.Hosting.Server.IHttpApplication`1<!!0>)'.
... (end stack trace)

D:\proj\nswagnetfull.csproj(54,5): error MSB3073: The command ""C:\Users\bob\.nuget\packages\nswag.msbuild\11.19.1\build\../tools/Win/NSwag.exe" run nswag.json" exited with code -1.

You can find a sample project with the to reproduce the issue at https://github.com/nicholas-brooks/nswag-aspnetcore-netfull-issue

Let me know if you need any more info.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicholas-brookscommented, Apr 10, 2019

@RicoSuter and @pranavkm - I can confirm that NSWag v12.1.0 resolves the issue as I originally defined. My repo I referenced has been updated with the fix. I also tested the same repo using asp.net core 2.2 and it also works as expected (using nswag v12.1.0). I consider this issue resolved.

Thanks for your awesome work on nswag!

0reactions
pranavkmcommented, Apr 10, 2019

@RicoSuter are you able to reproduce the error using the application @nicholas-brooks provided? I just tried it now, and it built fine:

Restoring packages for D:\temp\nswag-aspnetcore-netfull-issue\nswagnetfull.csproj...
...
Installing Microsoft.Extensions.Primitives 1.0.1.
Generating MSBuild file D:\temp\nswag-aspnetcore-netfull-issue\obj\nswagnetfull.csproj.nuget.g.props.
Generating MSBuild file D:\temp\nswag-aspnetcore-netfull-issue\obj\nswagnetfull.csproj.nuget.g.targets.
Restore completed in 3.16 sec for D:\temp\nswag-aspnetcore-netfull-issue\nswagnetfull.csproj.
nswagnetfull -> D:\temp\nswag-aspnetcore-netfull-issue\bin\Debug\net47\nswagnetfull.exe
nswagnetfull -> D:\temp\nswag-aspnetcore-netfull-issue\bin\Debug\net47\nswagnetfull.Views.dll
v10.14.1
Restoring dependencies using 'npm'. This may take several minutes...
...
added 1560 packages from 1339 contributors and audited 23223 packages in 24.75s
found 129 vulnerabilities (21 low, 85 moderate, 23 high)
run `npm audit fix` to fix them, or `npm audit` for details
NSwag command line tool for .NET 4.6.1+ WinX64, toolchain v12.1.0.0 (NJsonSchema v9.13.28.0 (Newtonsoft.Json v11.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Users\Pranav\.nuget\packages\nswag.msbuild\12.1.0\tools\Win

Executing file 'nswag.json'...
Launcher directory: D:\temp\nswag-aspnetcore-netfull-issue\bin\Debug\net47
Done.

Duration: 00:00:06.2208832

@farlee2121 do you have an application that you could share where the problem reproduces?

Read more comments on GitHub >

github_iconTop Results From Across the Web

MissingMethodException when running NSwag run ...
I've been trying to get NSwag to generate a typescript file for an ASP.NET Core application for the net47 target.
Read more >
ASP.NET Core error on building with NSwag Error MSB3073
NSwag fails when two methods of the same controller share the same HTTP GET (or HTTP ... tools/NetCore22/dotnet-nswag.dll" run nswag.json ...
Read more >
ASP.NET Core Web API (OpenAPI) Client issue ...
For this issue, it seems that you are missing the namespace reference. Try to install or re-install the relates package. Besides, whether your ......
Read more >
Get started with NSwag and ASP.NET Core
Learn how to use NSwag to generate documentation and help pages for an ASP.NET ... AspNetCore" package from the Browse tab and click...
Read more >
nswag error in .NET Core 3.1 #8719
Hi,. I am using .NET Core 3.1 & Angular 8. I am facing an issue when running refresh.bat. It's throwing me below mentioned...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found