RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.7k stars 1.24k forks source link

Could not load type 'System.Object' from assembly System.Private.CoreLib #918

Closed ranouf closed 7 years ago

ranouf commented 7 years ago

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.b14_1(MethodInfo m) at System.Linq.Enumerable.<>c__DisplayClass6_0`1.b0(TSource x) at System.Linq.Enumerable.WhereArrayIterator1.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(IEnumerable1 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.d2.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.<b77_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.d77.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.d76.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.d29.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.d28.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.<>cDisplayClass15_0.<b0>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.<>cDisplayClass14_0.<b0>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()

RicoSuter commented 7 years ago

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)

RicoSuter commented 7 years ago

Did you publish the app first? With all dlls?

RicoSuter commented 7 years ago

https://github.com/RSuter/NSwag/issues/905#issuecomment-326147207

ranouf commented 7 years ago

So I added "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0\System.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.d1.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.d2.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.<b77_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.d77.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.d76.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.d29.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.d28.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.<>cDisplayClass15_0.<b0>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.<>cDisplayClass14_0.<b0>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()

RicoSuter commented 7 years ago

Paths must be directories, try:

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

Or try this (paths to dlls):

image

josemotta commented 7 years ago

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

RicoSuter commented 7 years ago

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

josemotta commented 7 years ago

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

RicoSuter commented 7 years ago

Can you provide a repro sample project?

ranouf commented 7 years ago

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()
ranouf commented 7 years ago

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

RicoSuter commented 7 years ago

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

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

RicoSuter commented 7 years ago

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...

RicoSuter commented 7 years ago

Closed, see duplicate:

https://github.com/RSuter/NSwag/issues/922#issuecomment-328627029

ranouf commented 7 years ago

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?

ranouf commented 7 years ago

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?

RicoSuter commented 7 years ago

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

ranouf commented 7 years ago

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:

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.

RicoSuter commented 7 years ago

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

ranouf commented 7 years ago

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?

RicoSuter commented 7 years ago

https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/2662/artifacts

RicoSuter commented 7 years ago

MSI installer:

https://ci.appveyor.com/api/buildjobs/t6c0nl7nf9w4j4ra/artifacts/src%2FNSwagStudio.Installer%2Fbin%2FRelease%2FNSwagStudio.msi

ranouf commented 7 years ago

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

RicoSuter commented 7 years ago

Currently you cannot output in multiple files..

Can you post the error messages?

ranouf commented 7 years ago

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> {
[...]
}
}
RicoSuter commented 7 years ago

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

RicoSuter commented 7 years ago

OperationGenerationMode

ranouf commented 7 years ago

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!

RicoSuter commented 7 years ago

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

ranouf commented 7 years ago

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.b14_1(MethodInfo m) in C:\projects\nswag-25x6o\src\NSwag.SwaggerGeneration.WebApi\WebApiToSwaggerGenerator.cs:line 221 at System.Linq.Utilities.<>c__DisplayClass1_0`1.b0(TSource x) at System.Linq.Utilities.<>cDisplayClass1_01.<CombinePredicates>b__0(TSource x) at System.Linq.Enumerable.WhereArrayIterator1.MoveNext() at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.d11.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.d9.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.d1.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(IEnumerable`1 controllerClassNames, String settingsData) in C:\projects\nswag-25x6o\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\WebApi\WebApiAssemblyToSwaggerGenerator.cs:line 104 at NSwag.SwaggerGeneration.WebApi.WebApiAssemblyToSwaggerGenerator.d2.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.d72.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.d71.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.d36.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.d7.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.d5.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.d4.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.d12.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.

RicoSuter commented 6 years ago

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

ranouf commented 6 years ago

Hi

I went on https://github.com/RSuter/NSwag/wiki/NSwagStudio Then https://appveyorcidata.blob.core.windows.net/rsuter-25659/nswag/883/801i3yadahxnm087/src/NSwagStudio.Installer/bin/Release/NSwagStudio.msi?sv=2015-12-11&sr=c&sig=2vroqi5mabmmUYBKV3dOXS15HJaEiFBMQw%2BknXEtTzE%3D&st=2017-09-25T16%3A37%3A49Z&se=2017-09-25T16%3A43%3A49Z&sp=r

And there is an error: The specified blob does not exist. RequestId:19451556-001e-001d-561c-36630e000000 Time:2017-09-25T16:38:48.3997310Z

RicoSuter commented 6 years ago

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

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

RicoSuter commented 6 years ago

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

RicoSuter commented 6 years ago

Ok, now the link works again with v11.8.1

RicoSuter commented 6 years ago

Please report if anything works as expected...

ranouf commented 6 years ago

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!