BotBuilder-Samples icon indicating copy to clipboard operation
BotBuilder-Samples copied to clipboard

'Create New Conversion' Sharp sample doesn't work.

Open lin-zy1229 opened this issue 8 years ago • 21 comments

SDK Platform

.NET

URL of Code Sample

https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-CreateNewConversation

Problem Description

It builds and runs in Chrome successfully. But not shows Bot message, and even can't send user message,

image

image

Visual Studio 2017, Bot Framework Emulator v3.5.36 As you can see, I am testing in local and nothing changed in source code. What is the problem?

lin-zy1229 avatar Jun 21 '18 00:06 lin-zy1229

Hi @lin-zy1229, please update the BotBuilder SDK to 3.15.2 and try again.

stevkan avatar Jun 21 '18 18:06 stevkan

once upgrade, seems better, but still failing.

image

lin-zy1229 avatar Jun 22 '18 01:06 lin-zy1229

First, have you set the BotId, MicrosoftAppId, and MicrosoftAppPassword in the Web.config file? To be clear, you can run the bot locally without values entered. However, if you want to connect your local instance to an online instance, you will need values to be entered.

Second, the emulator should match your local instance. That is, if you don't provide the above values, then the values in the Bot Framework Emulator should also be empty. If you do provide values, you will also need to provide them in the emulator, as well.

Third, if you are wishing to connect your local instance to your Azure instance, you will need to use ngrok. Here is a blog detailing how to set that up.

Hope of help!

stevkan avatar Jun 22 '18 23:06 stevkan

This is current setting, and nothing changed in source code as mentioned first. (I also tried with '<add key="BotId" value="" />', but same.) I just want to run this bot locally in emulator.

image

lin-zy1229 avatar Jun 23 '18 00:06 lin-zy1229

I tried this sample code with the bot emulator and run into the same issue mentioned by @lin-zy1229 . Do you have any progress on this issue @lin-zy1229 ?

Thanks!

dhinag avatar Jun 25 '18 02:06 dhinag

Not yet, @dhinag.

lin-zy1229 avatar Jun 26 '18 13:06 lin-zy1229

@lin-zy1229 and @dhinag,

If you wish to run purely local, be sure the app is running in VS. Your Web.config settings should look like this: csharp no app settings

If you are using the v3 emulator, then your emulator settings should look like this: csharp v3 emulator no settings

If you are using the v4 emulator, then your emulator settings should look like this: csharp v4 emulator no settings

stevkan avatar Jun 26 '18 16:06 stevkan

Thanks @stevkan. I'll ensure that my settings mimic your settings and let you know.

dhinag avatar Jun 27 '18 14:06 dhinag

@stevkan I wanted to try out this sample today and I'm getting the same exception as above while trying to run the bot locally (in development) and using the V4 bot emulator. The settings in the bot emulator: capture

The settings in web.config

  <appSettings>
    <!-- update these with your BotId, Microsoft App Id and your Microsoft App Password-->
    <add key="BotId" value="" />
    <add key="MicrosoftAppId" value="" />
    <add key="MicrosoftAppPassword" value="" />
  </appSettings>

Relevant nuget packages (after suggested update):

  <package id="Microsoft.Bot.Builder" version="3.15.2.2" targetFramework="net46" />
  <package id="Microsoft.Bot.Builder.Azure" version="3.15.2.2" targetFramework="net46" />
  <package id="Microsoft.Bot.Builder.History" version="3.15.2.2" targetFramework="net46" />
  <package id="Microsoft.Bot.Connector" version="3.15.2.2" targetFramework="net46" />

For clarity, the received error message is:

Exception: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ScoringEventLoop1 (DelegateActivator), Services = [Microsoft.Bot.Builder.Base.IEventLoop], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> 
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ReactiveDialogTask (ReflectionActivator), Services = [Microsoft.Bot.Builder.Dialogs.Internals.ReactiveDialogTask], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> 
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Func1 (DelegateActivator), Services = [System.Func1[[Microsoft.Bot.Builder.Dialogs.IDialog1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], Microsoft.Bot.Builder, Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]], Lifetime = Autofac.Core.Lifetime.MatchingScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> 
Sequence contains no elements (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)
[File of type 'text/plain']

Looking at that message it seems something's going wrong while trying to resolve an instance of IDialog. Maybe the DI setup for CreateNewConversationDialog isn't working properly? I should mention that I can run some of the other samples with the emulator with no issues. (eg SimpleEchoBot, MultiDialogsBot)

cristi-badila avatar Jun 28 '18 13:06 cristi-badila

Hi @cristi-badila, I changed the properties of my project to match those of yours and it still runs fine for me in v3 and v4 emulator. Just to be clear, are you also trying the "core-CreateNewConversation" sample? And, can you verify you made no code changes other than clearing out appSettings values?

stevkan avatar Jul 03 '18 01:07 stevkan

Hi @stevkan, indeed I can confirm that I'm trying out the core-CreateNewConversation sample. I initially just cloned the repository and ran the sample as is without modifying any of the project files and encountered the mentioned exception. I then tried updating the Microsoft.Bot.* dependencies of the solution to 3.15.2.2 as per the advice you gave further up in this thread and unfortunately the exception persisted. Please let me know if I can help in any other way.

cristi-badila avatar Jul 03 '18 04:07 cristi-badila

I just tested this today and have been able to get it working with the latest package 3.15.3 in the v3 emulator. Is anyone else able to do so?

JasonSowers avatar Jul 03 '18 21:07 JasonSowers

Hi @JasonSowers, I just tried it again (I updated the bot builder to 3.15.2.2.), and got this error in v4 emulator:

[FileLoadException: Could not load file or assembly 'Microsoft.Bot.Builder, Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

I tried with v3 emulator and got 500 Internal Server error. It is probably the same error behind the scene.

Here is my web.config settings.

  <appSettings>
    <!-- update these with your BotId, Microsoft App Id and your Microsoft App Password-->
    <add key="BotId" value="" />
    <add key="MicrosoftAppId" value="" />
    <add key="MicrosoftAppPassword" value="" />
  </appSettings>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bot.Connector" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.11.1.0" newVersion="3.11.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bot.Builder" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.11.0.0" newVersion="3.15.2.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Azure.Documents.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.11.0.0" newVersion="1.11.0.0" />
      </dependentAssembly>

Please note that I did not update any other package other than Microsoft.Bot.Builder. Should I also update some other package? I also tried manually updating my web.config file to below, but the error persisted. <bindingRedirect oldVersion="0.0.0.0-3.11.0.0" newVersion="3.15.2.2" />

dhinag avatar Jul 04 '18 02:07 dhinag

You say you are on version 3.15.2.2 and this is showing up in your error:

Could not load file or assembly 'Microsoft.Bot.Builder, Version=3.12.2.4.

Something strange is happening here. Can you try to correct this reference? You may even want to try with a fresh project. I’ll continue troubleshooting this sample for issues. Can you also update the other botbuilder packages in your project too? It may be one of those referencing 3.12.2.4.

JasonSowers avatar Jul 04 '18 05:07 JasonSowers

@JasonSowers initially I had tried the sample with only the v4 emulator however I tried today the v3 one as well. Here's my experience:

  • I started out by updating to v 3.15.3 of the framework but I immediately found an issue in that the Microsoft.Bot.Builder.Azure package doesn't have a 3.15.3 version published; only 3.15.2.2. So out of the gate I couldn't run the sample since trying to run the app with some packages on 3.15.3 and Microsoft.Bot.Builder.Azure on 3.15.2.2 throws an exception as the later will try to load 3.15.2.2 assemblies.
  • Next I tried running the sample with all the framework dependencies on 3.15.2.2 and the emulator on version 3.5.36. With this setup the initial conversation is started however whenever I type a message into the dialog (so as to get the conversations started) I encounter a 500 error with no more details. capture

I've pushed the code here: https://github.com/cristi-badila/botframework-new-conversation.

cristi-badila avatar Jul 04 '18 06:07 cristi-badila

Thanks for the details and putting your project in a repo for me. Holiday today so I will take a look tomorrow.

JasonSowers avatar Jul 04 '18 18:07 JasonSowers

I just tested with 3.15.3 and botbuilder-azure 3.13.2.2 with no issues. I will look at your project in your repo now.

JasonSowers avatar Jul 05 '18 14:07 JasonSowers

@cristi-badila I am getting the same results with your project, yet my project is working. I have submitted a pull request against your repo here https://github.com/cristi-badila/botframework-new-conversation/pull/1 can you please try it with those changes and let me know the results. If it works for you I will submit a pull request against the main sample to update it as well. This is odd because for myself and other members of my team we are having no issue running the sample 👎 @dhinag @lin-zy1229 can you 2 also confirm that the code works for you as well in https://github.com/cristi-badila/botframework-new-conversation once @cristi-badila merges my pull request. or you can find the changes in my fork here https://github.com/JasonSowers/botframework-new-conversation

JasonSowers avatar Jul 06 '18 22:07 JasonSowers

@JasonSowers thanks for your help. Indeed your PR fixed the issue. I can now successfully run the sample together with the bot framework emulator v3.5.36 (latest v3 release). For completeness I should mention however that trying to run the sample with the v4.0.15-alpha emulator (latest v4 release) the sample gets stuck when calling line 25 in the SurveyTriggerer:

var conversation = await client.Conversations.CreateDirectConversationAsync(message.Recipient, message.From);.

No error occurs, but the call never completes and weirdly it doesn't seem to timeout either. Anyway, having the sample work with the v3 emulator should be enough I think to get me in the right direction. Thanks again 👍

cristi-badila avatar Jul 08 '18 06:07 cristi-badila

@cristi-badila thanks again for your patience and for reporting this issue. I will keep investigating this until I can find a resolution such that the sample should just work as is for all customers in any emulator version. I'm glad I was able to get you a version that you can use as a starting point. Best of luck and please keep reporting any issues you find.

JasonSowers avatar Jul 09 '18 18:07 JasonSowers