[Method not found]: ‘Void Microsoft.Bot.Connector.ConnectorClient…ctor(System.Uri, System.String, System.String, System.Net.Http.DelegatingHandler[])
Bot Info
- Bot handle: dev-facecheckin
- App ID: 37726bdb-616f-4bad-b0e6-08b562ea838a
- SDK Platform: .NET
- SDK Version: 3.9.0
- Active Channels: Teams
- Deployment Environment: Local / Azure App Service
Issue Description
I'm using the BotFramework in an already existing .NET Framework project (this is likely where the issue is, but I'm at a loss trying to find the issue at this point). The bot responds to all chat except the 'init' command, which is where I want it to store some data, and generate some user objects based on their Teams data for future use. The bot works while using the seed project, but I need to integrate it into this already-existing web app. All functions right apart from this major issue.
When trying to generate a new client, using:
var client = new ConnectorClient(new Uri(ConfigurationManager.AppSettings["serviceUrl"]), ConfigurationManager.AppSettings["MicrosoftAppId"], ConfigurationManager.AppSettings["MicrosoftAppPassword"]);
I get back the exception:
“Method not found: ‘Void Microsoft.Bot.Connector.ConnectorClient…ctor(System.Uri, System.String, System.String, System.Net.Http.DelegatingHandler[])’.”
This is called in a method that passes the Activity to store some data and reply back to the user through the main channel in Teams.
Code Example
Inside the Dialogue:
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
string request = message.Text.ToLower();
if (request.Contains("init") )
{
await context.PostAsync("Attempting initialization...");
TeamsChatInitializer initializer = new TeamsChatInitializer();
await initializer.InitializeBot(context.Activity);
}
context.Wait(MessageReceivedAsync);
}
Inside the initializer object:
var client = new ConnectorClient(new Uri(ConfigurationManager.AppSettings["serviceUrl"]), ConfigurationManager.AppSettings["MicrosoftAppId"], ConfigurationManager.AppSettings["MicrosoftAppPassword"]);
Reproduction Steps
- Make a .NET framework project.
- Create a controller for the Messages, and input all the BotFramework goodness and Nuget Packages
- Try to create the ConnectorClient.
Expected Behavior
I expect it to generate the client and not throw an error.
Actual Results
I receive the error:
‘Void Microsoft.Bot.Connector.ConnectorClient…ctor(System.Uri, System.String, System.String, System.Net.Http.DelegatingHandler[])
Have you also tried with the simple overload ConnectorClient connector = new ConnectorClient(new Uri(ServiceUrl));? It's probably worth a shot
Still got the same error with the simple overload.
can you please post the comeplete code for TeamsChatInitializer
I ended up trying another route, through direct line and a fresh .NET project using the Direct Line nuget package. Same exact issue. Here is my code for that:
public static async Task<List<Activity>> SendDataToBot(BotEventDto input)
{
var client = new DirectLineClient(DirectLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
string inputString = JsonConvert.SerializeObject(input);
Activity message = new Activity
{
From = new ChannelAccount(ClientUserName),
Text = inputString,
Type = ActivityTypes.Invoke
};
await client.Conversations.PostActivityAsync(conversation.ConversationId, message);
return await ReadBotMessages(client, conversation.ConversationId);
}`
It doesn't even get into the function before it errors out, unless I remove the direct line connector code, then it hits the breakpoint.
Found my issue. It is actually related to System.Net.Http. Solution for me was here: 22781
Hi Am facing this issue occurring only with unit test project or webloadperformance test project. It works fine with a unit test created using a Console application project. Any pointers?
Error: System.MissingMethodException: Method not found: 'Void Microsoft.Bot.Connector.DirectLine.DirectLineClient..ctor(System.String, System.Net.Http.DelegatingHandler[])'.
@SoujanyaAK Did you try the method in 22781 in regards System.Net.Http?
If that doesn't work, I remember a lot of issues came from not targeting the same .net framework version between projects. It's been a little while since I've been on a bot framework related project, so my memory is a bit hazy.
Hi larryeby, when you fixed the System.Net.Http, did you do a Nuget install System.Net.Http on your project? Or how did you fix it? I am struggling for 15 hours with the problem of ConnectorClient method not found as well.
It's been awhile, but I remember explicitly targeting 4.0.0 of System.Net.Http. That link above should have some more information on how to fix the issue. Good luck!