botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Method not found]: ‘Void Microsoft.Bot.Connector.ConnectorClient…ctor(System.Uri, System.String, System.String, System.Net.Http.DelegatingHandler[])

Open larryeby opened this issue 9 years ago • 9 comments

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

  1. Make a .NET framework project.
  2. Create a controller for the Messages, and input all the BotFramework goodness and Nuget Packages
  3. 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[])

larryeby avatar Oct 19 '17 00:10 larryeby

Have you also tried with the simple overload ConnectorClient connector = new ConnectorClient(new Uri(ServiceUrl));? It's probably worth a shot

JasonSowers avatar Oct 19 '17 17:10 JasonSowers

Still got the same error with the simple overload.

larryeby avatar Oct 19 '17 18:10 larryeby

can you please post the comeplete code for TeamsChatInitializer

JasonSowers avatar Oct 19 '17 21:10 JasonSowers

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.

larryeby avatar Oct 24 '17 21:10 larryeby

Found my issue. It is actually related to System.Net.Http. Solution for me was here: 22781

larryeby avatar Oct 25 '17 00:10 larryeby

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 avatar Apr 25 '18 09:04 SoujanyaAK

@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.

larryeby avatar Apr 26 '18 05:04 larryeby

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.

Tiffastic avatar Aug 07 '18 08:08 Tiffastic

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!

larryeby avatar Aug 13 '18 21:08 larryeby