Error with Microsoft.Graph.User after upgrading Microsoft Graph Client Library

Kenta Matsunaga 60 Reputation points
2024-01-23T02:55:47.04+00:00

Hello, After updating the "Microsoft.Graph" version from 1.21.0 to 5.39.0 via the Nuget Package Manager in Visual Studio, I encountered the following error. How can this be fixed? CS0234:The type or namespace name 'User' does not exist in the namespace 'Microsoft.Graph' (are you missing an assembly reference?)

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,978 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChenLi-MSFT 235 Reputation points Microsoft Vendor
    2024-01-23T05:57:13.9633333+00:00

    Hi @Kenta Matsunaga,

    Version 1.21.0 uses Microsoft.Graph.Core 1.21.0 as dependencies, while version 5.39.0 uses Microsoft.Graph.Core 2.0.8 as dependencies. So the way they call will be different.

    In 5.39.0, there is no reference to Microsoft.Graph.User, just use using Microsoft.Graph;. Microsoft.Graph already includes User.

    For more detail, you can refer to the official documentation to Choose A Microsoft Graph Authentication Provider and Create requests.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

0 additional answers

Sort by: Most helpful