Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6234733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:32:24+00:00 2026-05-24T10:32:24+00:00

I am attempting to inject an object into my saga. Using the following endpoint,

  • 0

I am attempting to inject an object into my saga. Using the following endpoint, when the message arrives at the handle method of the saga the property is null.

The endpoint:

 public class EndpointConfig : IConfigureThisEndpoint, AsA_Server,  IWantToRunAtStartup
        {
            public void Run()
            {
                IOrderRepository orderRepository = new OrderRepository();
                Configure.Instance.Configurer.ConfigureProperty<CreateOrderSaga>(x => x.OrderRepository, orderRepository);
            }

// stop method removed
    }

The app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
  </configSections>

  <MsmqTransportConfig
    InputQueue="Fulfilment.CreateOrder.OrderRecievedMessage"
    ErrorQueue="error"
    NumberOfWorkerThreads="1"
    MaxRetries="3"
  />

  <UnicastBusConfig
   DistributorControlAddress=""
   DistributorDataAddress="">
    <MessageEndpointMappings>
      <add Messages="NServiceBus.Saga.TimeoutMessage, NServiceBus" Endpoint="timeoutmanager" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
</configuration>

and my Saga accepting messages as follows

    public class CreateOrderSaga : Saga<CreateOrderSagaData>,
            IAmStartedByMessages<OrderRecievedMessage>,
            IHandleMessages<OrderCompletedMessage>,
            IHandleMessages<OrderCancelledMessage>
        {
            public IOrderRepository OrderRepository { get; set; }
            public void Handle(OrderRecievedMessage message)
            {
var order = new Order();
 OrderRepository.SaveOrder(order);
            }

a null reference expection will be thrown when attempting to call SaveOrder(). Have i configured the dependency injection correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:32:25+00:00Added an answer on May 24, 2026 at 10:32 am

    NServiceBus will automatically do property injection for you so you only need to register your repository with the container:

    In your Init() method: (Implement IWantCustomInitialization on a separate class)

    Configure.Instance.ConfigureComponent< OrderRepository >([The lifecycle you want]);
    

    IWantToRunAtStartup is not meant for configuration tasks (use IWantCustomInitialization instead)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to inject an annotated variable into the REQUEST scope: Map<Key<?>, Object>
I am attempting to @Inject a @SessionScoped bean into a Filter @WebFilter(/*) public class
I am receiving the following error when attempting to inject my dao into a
I'm attempting to use Ninject to inject repositories into controllers of my MVC project.
Attempting to render a model object into a JSON structure via a partial, like
Attempting to insert an escape character into a table results in a warning. For
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Attempting to run a MIB based SNMP script and I running into an issue.
Attempting to set up Samba + OpenLDAP using nss_ldap. After joining Windows7 to Samba
Trying to integrate Spring 2.5.5 with Xfire 1.2.6, I'm attempting to inject one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.