1

I've installed the NServiceBus.StructureMap package from NuGet and property injection is no longer working on my Sagas. Here's my configuration code (using the generic host):

public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        Configure.With()
            .StructureMapBuilder(ConfigureStructureMap())
            .XmlSerializer();
    }

    private static IContainer ConfigureStructureMap()
    {
        ObjectFactory.Initialize(cfg =>
        {
            cfg.For<IBarcodeReader>().Use<DataMatrixBarcodeReader>();
            cfg.ForSingletonOf<IDocumentStore>().Use(() => InitializeStore());
            cfg.For<IDocumentSession>().Use(x => x.GetInstance<IDocumentStore>().OpenSession());
        });

        return ObjectFactory.Container;
    }

    private static IDocumentStore InitializeStore()
    {
        return new DocumentStore
        {
            Url = "http://localhost:8080/",
            DefaultDatabase = "db"
        }
        .Initialize();
    }
}

1 Answer 1

3

Setter injection is not on by default in StructureMap so you need to enable it Autowire setters using StructureMap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.