ArgumentNullException in CreateDirectConversation/CreateDirectConversationAsync Bot Framework 4

走远了吗. 提交于 2019-12-25 02:59:40

问题


I'm migrating a bot from MS Botframework 3 to 4. We had a function that would email various individuals daily. Moving the code to v4 appears valid, but the call returns an error from inside the framework.

The exception is thrown in the Microsoft.Bot.Connector.Authentication namespace, in the method MicrosoftAppCredentials(string appId, string password, HttpClient customHttpClient). The error is System.ArgumentNullException: 'Value cannot be null. Parameter name: clientId'. customHttpClient inside that method is null. I do not see a way to pass along an HttpClient. Maybe my implementation is wrong?

My code:

ChannelAccount userAccount = new ChannelAccount(_config.UncategorizedReportToEmail, _config.UncategorizedReportToEmail);
var botAccount = new ChannelAccount(_config.BotEmail, _config.BotEmail);
var connector = new ConnectorClient(new Uri(_config.EmailServiceUrl));
MicrosoftAppCredentials.TrustServiceUrl(_config.EmailServiceUrl);
// Next line is where the exception is thrown
var conversation = connector.Conversations.CreateDirectConversation(botAccount, userAccount);
var conversationId = conversation.Id;

回答1:


System.ArgumentNullException: 'Value cannot be null. Parameter name: clientId' 

This error is a result of appID/password not being read properly from the configuration file. Whether you're using a .bot file, a appsettings.json file, or a web.config file, please make sure your appID and password are correct.



来源:https://stackoverflow.com/questions/55407725/argumentnullexception-in-createdirectconversation-createdirectconversationasync

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!