问题
I'm following the Microsoft Graph tutorial to create and send a chat message to a Microsoft Teams channel from C#.
However, I'm getting an error when following the first example when trying to create a ChatMessage
object. (var chatMessage = new ChatMessage...
) The error is:
The type or namespace name 'ChatMessage' could not be found (are you missing a using directive or assembly reference?)
I've added the following references to my project already but none of them seem to contain the ChatMessage
class definition:
Microsoft.Graph
Microsoft.Graph.Core
Microsoft.Graph.Auth
The ChatMessage documentation gives me a little more information on the ChatMessage
resource type but doesn't tell me where I should get it from.
The only other thing I've found is Windows.ApplicationModel.Chat.ChatMessage, but I can't find windows.applicationmodel.chat
in Nuget, and I'm not sure if this is actually correct as there's no mention of it on the Graph tutorial page.
What am I doing wrong to be able to use the ChatMessage
object in the tutorial?
回答1:
In order to call into the Beta version of Microsoft Graph (i.e. /beta/...
), you need to use the Microsoft.Graph.Beta NuGet package, not the Microsoft.Graph package. The later only contains APIs that have been released (i.e. /v1.0/...
).
来源:https://stackoverflow.com/questions/58913955/microsoft-graph-chatmessage-namespace-missing-in-c-sharp