Giter Site home page Giter Site logo

xer.cqrs.extensions.autofac's People

Contributors

joel-jeremy avatar mvput avatar

Watchers

 avatar  avatar  avatar

xer.cqrs.extensions.autofac's Issues

Autofac exception "This resolve operation has already ended..."

Hi!

Thanks for this cool library (Xer.Cqrs.CommandStack). I'm going to use it in one of my projects. But when I tried to integrate it with Autofac I got an exception. Let me show a sample code.

[Fact]
public async Task ShouldExecuteSampleCommand()
{
    ContainerBuilder builder = new ContainerBuilder();
    builder.RegisterCqrsCore()
        .RegisterCommandHandlers(opt => opt.ByInterface(typeof(TestCommand).Assembly));

    using (var context = builder.Build())
    {
        var commandDelegator = context.Resolve<CommandDelegator>();
        var cmd = new TestCommand();

        // act
        await commandDelegator.SendAsync(cmd);
    }
}

As you can see this is just one more unit test. The difference with other unit tests is that this one is not only assert "Command Delegator" not null but also use it to execute test command.
This unit test throws following exception:

Xer.Delegator.Exceptions.NoMessageHandlerResolvedException : Error occurred while trying to resolve message handler for TestCommand.
---- Xer.Delegator.Exceptions.NoMessageHandlerResolvedException : Error encoutered while trying to retrieve an instance of Xer.Cqrs.CommandStack.ICommandAsyncHandler`1[Xer.Cqrs.Extensions.Autofac.Tests.Entities.TestCommand] from the container.
-------- System.ObjectDisposedException : This resolve operation has already ended. When registering components using lambdas, the IComponentContext 'c' parameter to the lambda cannot be stored. Instead, either resolve IComponentContext again from 'c', or resolve a Func<> based factory to create subsequent components from.
at Xer.Delegator.Resolvers.RequiredMessageHandlerResolver.ResolveMessageHandler(Type messageType)
at Xer.Delegator.MessageDelegator.SendAsync[TMessage](TMessage message, CancellationToken cancellationToken)....

I've tested with Autofac version 4.9.2 and 4.6.2. In both cases I have this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.