Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Unable to use swagger open api #47

Open
VenkateshSrini opened this issue Nov 13, 2022 · 6 comments
Open

Unable to use swagger open api #47

VenkateshSrini opened this issue Nov 13, 2022 · 6 comments

Comments

@VenkateshSrini
Copy link

@SteveSandersonMS ,
I tried to use basic minimal api as a wasm. I had enabled swagger. But unfortunately, it is failing with the below error

Unhandled Exception:
System.IO.FileNotFoundException:
File name: 'Microsoft.AspNetCore.OpenApi'
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.<>c.b__8_0(ApplicationPartAttribute name)
at System.Linq.Enumerable.SelectArrayIterator2[[Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute, Microsoft.AspNetCore.Mvc.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at System.Collections.Generic.EnumerableHelpers.ToArray[Assembly](IEnumerable1 source, Int32& length)
at System.Linq.Buffer1[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable1.<GetEnumerator>d__4[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at System.Linq.Enumerable.SelectManySingleSelectorIterator2[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Linq.Enumerable.ConcatIterator`1[[System.Reflection.Assembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services, IWebHostEnvironment environment)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllers(IServiceCollection services)
at Program.

$(String[] args)

The sample code is attached herewith.
wasm.api.csproj.zip

Could you please help?

@relcodedev
Copy link

relcodedev commented Jun 2, 2023

I am getting the same error.

@VenkateshSrini
Copy link
Author

@SteveSandersonMS Is there any suggestion that you can provide on this

@SteveSandersonMS
Copy link
Owner

Perhaps that assembly is loaded dynamically instead of being a proper assembly reference. I'm not sure. One thing you could try is referencing it directly. If that doesn't work I'd recommend working with the owners of that package to make sense of what it's doing to load it that isn't just a normal assembly reference.

@relcodedev
Copy link

Thanks. It is referenced directly. The project was created with dotnet new webapi --use-program-main. I made the changes to use wasi and this is the error I get. It does work if I use dotnet new web --use-program-main.

@SteveSandersonMS
Copy link
Owner

Thanks for the extra info.

I'm unsure why it's not working, though suspect it's something specific to how MVC is trying to load that assembly via reflection (based on your stack trace).

Since we're now switching over to the WASI support in .NET 8 Preview 4 and later, I'd recommend for any further prototyping you attempt to use that (i.e., the new wasi-experimental workload). It may well fail in the same way but if so it would be possible to file a bug about it and then hopefully we will address it, whereas no further work is going to happen in this repo here.

@relcodedev
Copy link

Got it. I will test with .net 8 preview latest. Thanks.

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

No branches or pull requests

3 participants