-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReflectionTypeLoadException: Unable to Load IBaseRequest and IAuthenticationProvider from assembly 'Microsoft.Graph.Core, Version=3.0.2.0 #629
Comments
Thanks for raising this @VorTechS Any chance you could share the contents of your .csproj to help us understand if there's another depenendecy trying to load an older version of the client? Alternatively, sharing a sample repro project would be great as well. |
Thanks for the reply. Here's the .csproj file contents:
Clearly, that's not everything as it's quite a large project there are other projects involved, I suspect the culprit may be one of the Azure packages (as we're using KeyVault and Blob storage)
... most of which have been updated to the latest versions to within the last few days. I haven't been brave enough to be updating any of the ASPNetCore binaries, yet! If necessary, I'm more than willing to put together a sample project with every package used throughout the entire project to see if that suffers the same fate. |
@andrueastman Is there any update on this issue? I also have a similar problem |
This is most likely caused by which still depends on Graph core 2.x.x. There is an update upcoming to resolve this from that side to resolve this. In the meantime you will need to use Graph v4 if you need the dependency. <PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.26.0" /> Any chance you are able to drop the dependency to verify? |
Sure. Removing that reference (and any associated code) did indeed resolve that particular issue. But then, I'm unable to do TokenAcquisition to push down to Graph in order to retrieve an Ad User List of members that have permissions to the application (the overall problem I am trying to solve). Graph v4 worked fine in development but when the application was pushed to Azure it behaved differently, returning an error related to JSON Deserialization (something along the lines of Expected Object, Received Array). Hence trying down this path of going to the latest binaries. So I'm stuck in between a rock and hard place here :) |
There will be an upcoming update to support the new version from In the meantime, we may be able to resolve json error from V4. Are you able to share details on what situation the error is occurring and on calling what endpoint? |
I'll put the source code back together as it was, re-deploy to the server and attach a debugger again to get the specific error. Like I said it only happens once deployed to the server, it doesn't happen on the local development machine(s). |
Well after re-enabling the previous v4.x code, it would appear we have a NEW error 😄 'Message: CompactToken parsing failed with error code: 80049217'
There's a chance it worked ONCE whilst I was stepping through and then subsequent calls (after a StateHasChanged() forces an update) fail with this error. But I've yet to go through more methodically and successfully prove that. |
Hey @VorTechS As you are trying to list all the users in the tenant, I believe you would need to pass one of the permissions listed at the link below. Any chance the error goes away if you change the API call made from var userListPage = await graphClient.Users.Request().GetAsync(); to var user = await graphClient.Me.Request().GetAsync(); There is the possibility that the user in the dev environment already has one of the permissions above to list all users in the tenant but the once deployed the user doesn't have this. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Sorry ended up fighting other fires that took me away from this. But at this point, this error is occurring attached to the Azure App Instance process, not locally. I'll try out your suggestion, and poke around a bit more, but it does work fine in dev. just not once deployed to the server. And my dev account doesn't have permissions (there seems to be a Visual Studio bug where it's ignoring the Azure user it's setup to use), so when I say it works in dev. I mean by launching a separate browser and signing in as an Azure User that has the correct permissions. |
So. I modified our 'Profile Menu' component to include the code you suggested, which does as follows:
On first render, the identity is correctly displayed: ...then a second call happens, running through exactly the same code and fails:
...and on that second call the graphAccessToken is blank. |
I updated the call to Token Acquisition to include the correct scopes as you suggested ("user.read.all ", "directory.read.all"), and now get a consent dialog for 'Need Admin Approval'. I've reached out to the tenant owner to grant the scopes in question and will see how that affects things. I'm guessing, from what I read here: ...that the previous calls to Token Acquisition was using an OpenId default on the first call - but then somehow gets lost on subsequent calls? |
I'm seeing this error: Opened separate issue: microsoftgraph/msgraph-sdk-dotnet#1854 |
Any update on this @VorTechS? |
Followed up at microsoftgraph/msgraph-sdk-dotnet#1854 |
Sorry. Yes. The tenant owner modified the scopes and the issue remains the same. It seems our Blazor Component Initialize event is firing twice (which I believe is normal), and the first time we ask for a Token, we get a token back, which can then be used to query graph as needed. On the second firing the token is coming back as null.
For now, caching that token on the first firing of the event and then re-using it on the subsequent firing seems to get round the issue although that's not ideal. Refreshing the page with the component on, consistently behaves the same. |
@VorTechS I first encountered this issue when working with Blazor. I'm now dealing with something similar in my api. In Blazor I found out the solution was to add |
I've had the ConsentHandling in place from the beginning:
|
So recently I updated all the binaries in our project, and we're now using: Azure.Core - 1.34 (and all the bits these come with) ... and I'm pleased to say this issue no longer happens. Multiple calls to fetch the current token appear to be working (whereas two calls one after the other used to fail), so I'm hoping I can remove the reliance on Token caching now! There's a potential this issue can be closed, but will confirm on Monday. |
Right! So I FINALLY have this working perfectly in production, after diagnosing a constantly looping authentication issue on a new deployment slot on Azure. The binary combination above is working perfectly well with an injected GraphServiceClient to achieve what we were struggling to achieve. The production vs development issue was down to the Client Secret in the App Service Deployment slot not being valid. Somewhere along the lines there appears to be a valid token when the component first renders (RenderMode = ServerPrerendered) and you can visibly see a user list before it renders a second time. On that second render, and subsequent call to the Graph API, the 'Client Secret' setting in the App Service Deployment Slot settings is used. In our deployment slot, this wasn't the same as the secret in the Visual Studio appsettings.json. Once the valid Client Secret was supplied in the deployment slot settings, the production server behaved as would be expected. I have no idea if this gives any useful information to anyone, or if anything can be learned from this subsequent analysis. |
Having encountered a problem with v4.x of the Microsoft.Graph NuGet packages, I decided to grab the latest version of the NuGet package for use in our .NET Core 6 Blazor project, written using Visual Studio 2022 on a Windows 10 machine.
Having followed the instructions for the Upgrade from v4 to the new v5 (starting with 5.01 and now 5.02),
I have the errors:
...when calling app.MapControllers() from my Program.cs during the application startup.
So I decided to download the source code which leaves you with a broken set of source code mostly related to: 'DoesUserHaveAccessuserIdUserIdTenantIdTenantIdUserPrincipalNameUserPrincipalNameRequestBuilder' and other similarly named classes which I can see live in separate folders but just don't make it down to a machine from either of the above.
(Possibly a file path character limit being hit?!)
Having battled through those issues, adding the missing classes and finally getting both Microsoft.Graph and Microsoft.Graph.Core building against .NET Core 6, I'm able to confirm I get the same errors from the source code as I do the NuGet package.
I can see mentions of IBaseRequest in previous commits living under Microsoft.Graph.Core.Requests, e.g:
073613f
.... but the current iteration of the project does not have this, and I can see from the documentation IBaseRequest is meant to have been dropped, yet somehow Reflection still seems to want to load it (presumably something from Kiota?)
The loaded source code project(s) have the following packages referenced:
...which are inline with the available NuGet packages.
Is can only surmise that there is a reference missing, something that I need to be including.
Can anyone give me any pointers please?
The text was updated successfully, but these errors were encountered: