IdentityModel: System.MissingMethodException when using `new DiscoveryClient(uri)`
When executing this
[HttpGet]
public async Task<IHttpActionResult> GetOpenId(string code, string state) {
var discoveryClient = new DiscoveryClient(issuerUri);
// rest omitted for brevity, it breaks here
}
I get
Method not found: 'Void IdentityModel.Client.DiscoveryClient..ctor(System.String, System.Net.Http.HttpMessageHandler)'.
Response from a Web Api 2 action:
<Error><Message>An error has occurred.</Message><ExceptionMessage>Method not found: 'Void IdentityModel.Client.DiscoveryClient..ctor(System.String, System.Net.Http.HttpMessageHandler)'.</ExceptionMessage><ExceptionType>System.MissingMethodException</ExceptionType><StackTrace> at Admin.OpenIdController.<GetOpenId>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at Admin.OpenIdController.GetOpenId(String code, String state)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass12.<GetExecutor>b__8(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</StackTrace></Error>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (10 by maintainers)
Tbh. I am sick of figuring out which part of the .net tooling is now broken again.
I am facing the same issue.
I have a project
IdentityServer4.Management
which has references toIdentityServer4.EntityFramework 1.0.1
andIdentityServer4.AccessTokenValidation 1.2.1
.In the Startup.cs I have:
Standalone, that project works fine. However, I have an integration tests project which has a reference to
IdentityServer4.Management
project. When I try to create a TestServer in the following way:I receive the following error message in the output of my test:
Not entirely sure what I am doing wrong.
Figured it out. I had to add a
<runtime>
binding redirect forSystem.Net.Http
for some reason…After that I could invoke the constructor without fail.
I have got similar issue for the constructor of IdentityModel.Client.TokenClient (in IdentityModel 3.8.0) and adding System.Net.Http to my project as package dependency resolved the issue.
Project target framework: .NET Framework 4.6.2
This also broke for me when updating VS 2017 to 15.4.4. I had to install .NET Framework 4.7 SDK from the VS installer and update my projects to target
net47
(previouslynet461
).