问题
I am trying to get list of Azure AD B2C users based on code sample provided Here.
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var users = await graphClient.Users
.Request()
.GetAsync();
Which is loading users as expected when I try with .Net core console application or .Net core web application. But I need to load users in .net core class library project. (Azure function project to be specific). But same code in .net core class library throws below expection while fetching user.
System.Private.CoreLib: Exception while executing function: MainFunction. System.Text.Json: The collection type 'Microsoft.Graph.IGraphServiceUsersCollectionPage' on 'Microsoft.Graph.GraphServiceUsersCollectionResponse.Value' is not supported.
I could not figure out any document or cause related to this error. Can anybody help me with this?
回答1:
I've had the exact same problem today but I updated all NuGet packages to latest pre-release versions and it's now working.
回答2:
Today, I had the same error, although I already had the latest pre-release packages installed.
I discovered that I recently explicitely installed the "Microsoft.Graph.Core" NuGet package.
Usually, this package is implicitely installed by "Microsoft.Graph.Auth" and "Microsoft.Graph.Beta".
I removed the explicitely installed NuGet package "Microsoft.Graph.Core" and then did the following call in the Package Manager Console in Visual Studio 2019:
Update-Package -Reinstall
After a rebuld of my project, the error went away.
回答3:
Weirdly enough, I ran into this problem when I upgraded the following packages:
Microsoft.Graph
Microsoft.Graph.Core
Initially, I was not sure why this error would have occurred.
To resolve it, I first tried Uwe Kleim's solution and ran Update-Package -Reinstall
. That did not work, but it did reinstall the package, so it may have helped (keep reading).
Next, I reverted the upgrade on the packages. I reverted Microsoft.Graph
first and then did a rebuild. The problem still existed. So, I reverted the upgrade on Microsoft.Graph.Core
and the problem went away. I then upgraded Microsoft.Graph
and then did a rebuild. This time, the error went away AND when I went to upgrade Microsoft.Graph.Core
, it was not available to be upgraded. So, it must have been upgraded with Microsoft.Graph
.
My best bet as to the root cause: I upgraded the packages in the wrong order and Visual Studio did not like that.
来源:https://stackoverflow.com/questions/62294508/the-collection-type-microsoft-graph-igraphserviceuserscollectionpage-on-micro