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

Autofac.Core.DependencyResolutionException in AlarmBot

Open kevinport opened this issue 10 years ago • 7 comments

I noticed that since the ResumptionCooki got 2 constructors the Sample AlarmBot did not work anymore.

Exception thrown: 'Autofac.Core.DependencyResolutionException' in Autofac.dll

Additional information: Cannot choose between multiple constructors with equal length 1 on type 'Microsoft.Bot.Builder.Dialogs.ResumptionCookie'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.

The error occurs in in AlarmModule.cs at this line:

builder.Register(c => new RenderingAlarmService(new AlarmService(c.Resolve<IAlarmScheduler>(), c.Resolve<ResumptionCookie>()), c.Resolve<Func<IAlarmRenderer>>(), c.Resolve<IBotToUser>(), c.Resolve<IClock>())).Keyed<IAlarmService>(FiberModule.Key_DoNotSerialize).AsImplementedInterfaces().InstancePerMatchingLifetimeScope(DialogModule.LifetimeScopeTag);

Like the error message says, use UsingConstructor(), i inserted this line above the error line: builder.RegisterType<ResumptionCookie>().UsingConstructor(typeof(IMessageActivity));

But is this the right way?

I think Sample code should alway work...

kevinport avatar Oct 17 '16 17:10 kevinport

We have this fixed in the develop branch - @msft-shahin have we done a release?

willportnoy avatar Oct 17 '16 19:10 willportnoy

ok that's great.

@willportnoy thank you for your fast response

kevinport avatar Oct 17 '16 19:10 kevinport

@kevinport this should be fixed in the next release of bot builder. We are planing on having a bug fix release in the coming days.

msft-shahins avatar Oct 19 '16 05:10 msft-shahins

@msft-shahins thanks.

kevinport avatar Oct 19 '16 07:10 kevinport

close?

kevinport avatar Oct 30 '16 11:10 kevinport

@kevinport this should be fixed with the 3.3 release. do you still see this?

msft-shahins avatar Oct 30 '16 23:10 msft-shahins

@msft-shahins yes it is fixed, i only ask to close :)

kevinport avatar Nov 01 '16 12:11 kevinport