How to fixTypeLoadException: Could not load type 'Microsoft.Graph.IAuthenticationProviderOption' from assembly 'Microsoft.Graph.Core, Version=3.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I am using Microsoft Graph 5.69 <PackageReference Include="Microsoft.Graph" Version="5.69.0" />
Each time, I register the Microsoft Graph service in program.cs
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"));
builder.Services.AddMicrosoftGraph(options =>
{
options.BaseUrl = "https://graph.microsoft.com/v1.0/";
options.Scopes = "User.Read";
});
// Add authorization
builder.Services.AddAuthorization();
and run the app, I get the following error
An unhandled exception occurred while processing the request.
TypeLoadException: Could not load type 'Microsoft.Graph.IAuthenticationProviderOption' from assembly 'Microsoft.Graph.Core, Version=3.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Microsoft.Identity.Web.GraphServiceCollectionExtensions+<>c.<AddMicrosoftGraph>b__1_0(IServiceProvider serviceProvider)
How can I fix this?