bruno-garcia / Bazinga.AspNetCore.Authentication.Basic

Basic Authentication for Microsoft ASP.NET Core Authentication
MIT License
48 stars 13 forks source link

MissingMethodException at runtime #3

Closed springy76 closed 6 years ago

springy76 commented 6 years ago

My debugger doesn't reach the entire Startup.ConfigureServices method at all, runtime throws MissingMethodException while trying to JIT it.

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Microsoft.AspNetCore.Authentication.AuthenticationBuilder Microsoft.Extensions.DependencyInjection.BasicAuthenticationExtensions.AddBasicAuthentication(Microsoft.AspNetCore.Authentication.AuthenticationBuilder, System.Func`2<System.ValueTuple`2<System.String,System.String>,System.Threading.Tasks.Task`1<Boolean>>)'.
  Source=AspNetCoreWebApplication_API
  StackTrace:
   at AspNetCoreWebApplication_API.Startup.ConfigureServices(IServiceCollection services) in MyCode
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at AspNetCoreWebApplication_API.Program.BuildWebHost(Int32 port) in MyCode

The only line I added was this one: authBuilder.AddBasicAuthentication(tuple => Task.FromResult(true));

@Microsoft Thank you Microsoft for trading strong references which fail at compile time against soft references which just can fail any time any where.

bruno-garcia commented 6 years ago

Could you please describe your environment a little bit? What kind of system is this running? net47 or netcoreapp2.0, on Windows or Linux and which version.

Could you also describe how are you starting the app (e.g: dotnet /path/to/App.dll) and also verify if the DLL brought in by the NuGet package (Bazinga.AspNetCore.Authentication.Basic.dll) is at your deployment directory? Perhaps it wasn't included during your build packaging.

With a bit more input we can try to narrow down the issue.

springy76 commented 6 years ago

I'm targetting net46x. I meanwhile switched from NuGet package to full source but still same problem, even after consolidating versions of referenced NuGet packages.

Switching to net471 removes the problem.

Manually referencing System.ValueTuple 4.4.0 (against net461) does NOT remove the problem.

The output directory seems to contain all DLLs. Any idea for narrowing this down? It's not a show-stopper since I could use net471. But I personally hate it when I don't understand it, and I have another project (not older than a few months) which just cannot be migrated from net462 to net471 without breaking everything related to System.Net.Http.

bruno-garcia commented 6 years ago

This project is packaged as a netstandard2.0 library so it should be supported by net461.

Is it possible to provide a repro? A small repository where I could reproduce locally and try to identify the problem?

springy76 commented 6 years ago

I wish I could reproduce. The original project already only was a slightly modified original WebApi template. But a completely new project doesn't show this problem -- though on a different computer.

springy76 commented 6 years ago

I can't reproduce on the other computer either. Maybe it's because I installed this 4.7.1 update on both PCs this week: Applications targeting .NET 4.6.1 that use .NET Standard libraries might be broken when running on .NET 4.7.1

bruno-garcia commented 6 years ago

That explains. Glad the problem is gone.