Nswag: Could not load type 'System.Object' from assembly System.Private.CoreLib

Created on 1 Sep 2017  ·  37Comments  ·  Source: RicoSuter/NSwag

Hi,

Framework Asp.Net Core 2.0
Angular 4

Can you help to fix this error:

Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

Server stack trace:
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte* ppBlob, Byte pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit)
at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<>c.b__14_1(MethodInfo m)
at System.Linq.Enumerable.<>c__DisplayClass6_01.<CombinePredicates>b__0(TSource x) at System.Linq.Enumerable.WhereArrayIterator1.MoveNext()
at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable`1 controllerClassNames, String settingsData)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable1 controllerClassNames, String settingsData) at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.<b__77_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocumentBase.d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocumentBase.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwagStudio.ViewModels.DocumentViewModel.<>c__DisplayClass15_0.<b__0>d.MoveNext() in C:\Data\Projects\NSwag\src\NSwagStudio\ViewModels\DocumentViewModel.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass14_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyToolkit.Mvvm.ViewModelBase.d__12`1.MoveNext()

NSwag.AssemblyLoader await-repro bug

All 37 comments

This is a new one :) try adding the assembly in question to the assemblies list (you can add multiple assembly paths in the ui, one per line)

Did you publish the app first? With all dlls?

So I added "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0System.Private.CoreLib.dll"
on a new line in "Paths to search"
In C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0 I can see System.Private.CoreLib.dll.

When I try to generate the code, I have this error:
The directory name is invalid.
System.IO.IOException: The directory name is invalid.

Server stack trace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator1.CommonInit() at System.IO.Directory.GetDirectories(String path, String searchPattern, SearchOption searchOption) at NSwag.CodeGeneration.Infrastructure.AssemblyLoader.RegisterReferencePaths(IEnumerable1 referencePaths)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable`1 controllerClassNames, String settingsData)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable1 controllerClassNames, String settingsData) at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.<b__77_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocumentBase.d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocumentBase.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwagStudio.ViewModels.DocumentViewModel.<>c__DisplayClass15_0.<b__0>d.MoveNext() in C:\Data\Projects\NSwag\src\NSwagStudio\ViewModels\DocumentViewModel.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass14_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyToolkit.Mvvm.ViewModelBase.d__12`1.MoveNext()

Paths must be directories, try:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0

Or try this (paths to dlls):

image

I got this error with NSwag v11.5.0 (Build 866), are you sure you have latest NSwag v11.5.1?

Was just a demo, not a repro. Can you provide one?

Just informing ranouf to check the latest version that fixed this error

Can you provide a repro sample project?

Hi,

So C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0 was already in my Paths to search, and I have:
C:\Users\XX\Documents\Visual Studio 2017\Projects\XXX\WikikiBXXXackend.Web\bin\Release\PublishOutput

I updated to the last version, and I have the same error:
Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist.

Server stack trace: 
   at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
   at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit)
   at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<>c.<GetActionMethods>b__14_1(MethodInfo m)
   at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
   at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
   at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<GenerateForControllerAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<GenerateForControllersAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.<GenerateForControllersAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable`1 controllerClassNames, String settingsData)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable`1 controllerClassNames, String settingsData)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.<GenerateForControllersAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.WebApiToSwaggerCommandBase.<<RunAsync>b__77_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.WebApiToSwaggerCommandBase.<RunAsync>d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.WebApiToSwaggerCommandBase.<RunAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.NSwagDocumentBase.<GenerateDocumentAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwag.Commands.NSwagDocumentBase.<ExecuteAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NSwagStudio.ViewModels.DocumentViewModel.<>c__DisplayClass15_0.<<GenerateAsync>b__0>d.MoveNext() in C:\projects\nswag\src\NSwagStudio\ViewModels\DocumentViewModel.cs:line 46
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass14_0.<<RunTaskAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MyToolkit.Mvvm.ViewModelBase.<RunTaskAsync>d__12`1.MoveNext()

My project is too big to be able to reproduce it sorry. Do you have other suggestions?

Have you tried to manually add the System.Private.CoreLib to AssemblyPaths?

=> https://github.com/RSuter/NSwag/wiki/Assembly-loading#troubleshooting

My problem is that I don't have a large .NET Core 2.0 project to test NSwag - all my core projects are currently still on 1.1... Isnt there a way to reproduce this in an "empty" project?

The simplest solution is to use the NSwag middleware to serve the spec directly from the ASP.NET Core process, but this way you cannot generate the spec from cmd line...

Hi,

i m not sure to understand. I read the other Issue (#922), so currently, there is no solution, the only way to generate the TypeScript services used for angular is with the command line:
nswag run nswag.json /runtime:core2.0

Do I Understand well the situation?

So I downloaded the file : https://localhost:XXXXX/swagger/v1/swagger.json
Then I executed the command:
nswag run XXXX\swagger.json /runtime:core2.0
Then I have:
NSwag command line tool for .NET 4.6.1+, toolchain v11.6.1.0 (NJsonSchema v9.5.0.0) (x64)
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Program Files (x86)\Rico Suter\NSwagStudio

Executing file 'XXX.Web\swagger.json'...
Done.

Duration: 00:00:02.6554803

This is my nswag configuration:

image

And, my generated angular Service Ts file is supposed to be updated?

Current the file is not updated, maybe there is something is misconfigured or I dont understand ...

Can you give me more details please?

Please test this new feature: https://github.com/RSuter/NSwag/issues/953
(not released yet, try CI)

Hi,

Thank you for your reactivity :)
So I created a sample project and I tried to configure NsWagStudio with it, here is the branch with the configuration:
https://github.com/ranouf/AspNetCore2Angular4/tree/nswag

There is 2 tests:

  • swagger.config.nswag, the problem is I dont have the name of the Controller, so all the functions are in the same class. I would like something like TestSetvice.GetTests and SampleService.GetSamples. I m looking to find the solution. Currently i had to set [SwaggerOperation("XXXX")] on each function of the controller, If not the name of the function is based on the Url, I would to automatize the naming avoiding me to write the attribute each time.
  • api.config.nswag, i still have the same pb with the file generation:
    "System.TypeLoadException: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist."

I went to https://github.com/RSuter/NSwag/issues/953. I m not sure what I have to do to test your fix, i have the last version available (v11.7.2.0) but in the WebApi Assemble Tab there is not Runtime DropDown.

Thank you for you help.

You have to download the CI build from the AppVeyor build server... the new Runtime option is not released yet.

So i went to https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/2662, but nowhere i can download any file. I signin too just in case the link is available only for logged in users, but it didnt work
Do I need to do something to see the link?

Thanks, So i downloaded the app. When I open it, i have error messages, but it works! I can generate the file with my Sample Project (https://github.com/ranouf/AspNetCore2Angular4/tree/nswag).

I updated the settings, but strangely I have the same problem as i have with swagger.config.nswag, all my functions are in the same Class Service :
https://github.com/ranouf/AspNetCore2Angular4/blob/nswag/Test1.Web/ClientApp/app/services/api.services.ts

I would like something like SampleService and TestService. Is there an option to enable in the nswag studio app?

[EDITED] It works now 🥇 !! (Currently it s not working on my main project, i will work more on it and I let you know if it s work :))

Thanks

Currently you cannot output in multiple files..

Can you post the error messages?

I reopen the app, there is no error message anymore. Sorry I didnt take a screenshot of them the first time.

About all the functions in the same class, it s not I would like to have them in different files, i would like in the same file but in different class, exemple:

export class SampleService extends ServiceBase {
[...]
getSample(id: string): Observable<SampleDto | null> {
[...]
}
}
export class TestService extends ServiceBase {
[...]
getTest(id: string): Observable<TestDto | null> {
[...]
}
}

Currently I have :

export class OfferService extends ServiceBase {
[...]
getSample(id: string): Observable<SampleDto | null> {
[...]
}

[...]
getTest(id: string): Observable<TestDto | null> {
[...]
}
}

I think you can use

SwaggerOperation(“Sample_GetSample”)

And use multiple clients from operation id in the code generator settings and “{client}Service” as client name

OperationGenerationMode

I found the solution :)

I removed the [SwaggerOperation] Attribute from my Controllers, and now I have different class for each controller.

The issue is now resolved!

Yes, by default, the operation ids are generated in the form "Controller_Action" which are then splitted and grouped by the code generators...

Hi,

I just Added Identity core and now I have a new error when I went to use nswag:

NSwag command line tool for .NET Core, toolchain v11.7.2.0 (NJsonSchema v9.6.3.0) (x64)
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Program Files (x86)\Rico Suter\NSwagStudio\NetCore20

Executing file 'C:\Users\SideKick\AppData\Local\Temp\nswag_document_b1b7e2de-924c-4f22-9d9c-82fd63451d4a_config.json'...
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Identity.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Identity.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'Microsoft.Extensions.Identity.Core'
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte* ppBlob, Byte pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit)
at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<>c.b__14_1(MethodInfo m) in C:\projects\nswag-25x6o\src\NSwag.SwaggerGeneration.WebApi\WebApiToSwaggerGenerator.cs:line 221
at System.Linq.Utilities.<>c__DisplayClass1_01.<CombinePredicates>b__0(TSource x) at System.Linq.Utilities.<>c__DisplayClass1_01.b__0(TSource x)
at System.Linq.Enumerable.WhereArrayIterator1.MoveNext() at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<GenerateForControllerAsync>d__11.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.SwaggerGeneration.WebApi\WebApiToSwaggerGenerator.cs:line 132 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.<GenerateForControllersAsync>d__9.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.SwaggerGeneration.WebApi\WebApiToSwaggerGenerator.cs:line 94 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.<GenerateForControllersAsync>d__1.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\WebApi\WebApiAssemblyToSwaggerGenerator.cs:line 115 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForControllers(IEnumerable1 controllerClassNames, String settingsData) in C:\projects\nswag-25x6o\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\WebApi\WebApiAssemblyToSwaggerGenerator.cs:line 104
at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.d__2.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\WebApi\WebApiAssemblyToSwaggerGenerator.cs:line 86
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.<b__72_0>d.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\Commands\WebApiToSwaggerCommandBase.cs:line 190
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__72.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\Commands\WebApiToSwaggerCommandBase.cs:line 172
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.WebApiToSwaggerCommandBase.d__71.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\Commands\WebApiToSwaggerCommandBase.cs:line 165
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocumentBase.d__36.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\NSwagDocumentBase.cs:line 226
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.NSwagDocument.d__7.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.AssemblyLoaderCore\NSwagDocument.cs:line 58
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.Document.ExecuteDocumentCommandBase.d__5.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:line 52
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.Document.ExecuteDocumentCommandBase.d__4.MoveNext() in C:\projects\nswag-25x6o\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag-25x6o\src\NSwag.Commands\NSwagCommandProcessor.cs:line 59

I did a publish in a local folder which is included in Nswag Configuration.
You can find the the project in this branch:
https://github.com/ranouf/AspNetCore2Angular4/tree/identity

For _AccountControler_ the app asks for _Microsoft.Extensions.Identity.Core_ and _AuthorizationController_, _Microsoft.Extensions.Identity.Stores_

Let me know if you need more details.

v11.8 has been released, please test your projects with it:

image

The wiki has been updated: https://github.com/RSuter/NSwag/wiki/Assembly-loading

Download it from here (v11.8.1) as soon as its released:

https://ci.appveyor.com/project/rsuter/nswag/build/885

I think the link is broken as long as a release is building :)

Ok, now the link works again with v11.8.1

Please report if anything works as expected...

I followed the instructions from here: https://github.com/RSuter/NSwag/wiki/Assembly-loading
I added in the csproj:
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
Every thing works perfectly!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rui90 picture Rui90  ·  4Comments

alanedwardes picture alanedwardes  ·  3Comments

Rui90 picture Rui90  ·  3Comments

p0wertiger picture p0wertiger  ·  3Comments

jjohs picture jjohs  ·  3Comments