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 9186875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:38:14+00:00 2026-06-17T19:38:14+00:00

I have a Service created with ServiceStack . I am using Funq for my

  • 0

I have a Service created with ServiceStack. I am using Funq for my Dependency Injection as it comes with ServiceStack by default, but this may be behaviour exhibited by other DI containers.

I register my types on startup:

this.AppContainer.RegisterAs<ConcreteDownloadServices, IDownloadServices>();`

I have this constructor in a class:

private readonly IDownloadServices downloadServices;

public ExampleService(IDownloadServices downloadServices)
{
    this.downloadServices = downloadServices;
}

And the constructor of my concrete implementation is:

public ConcreteDownloadServices()
{
    this.ArbitraryProperty = "ArbitraryString";
}

Everything resolves fine and I can step into the code and see things working as expected. However, AbritraryProperty does not get set properly. I can step through and see it set to the string value, but as soon as the code returns to the calling code (in this example, it would be the constructor of ExampleService) ArbitraryProperty is now null.

  1. Is this behaviour by design?
  2. If it is by design, does using DI mean that I shouldn’t be doing anything in the constructors of my concrete implementations?
  3. If it is by design, what’s the correct way to set default values for auto properties?
  4. If it is not by design, then what’s going on?
  • 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-06-17T19:38:15+00:00Added an answer on June 17, 2026 at 7:38 pm

    Edit:

    I’ve decided this is never desired behavior so I’ve just checked in a commit to enforce that Funq doesn’t autowire string (and ValueType) properties. The new behavior will be available in the next version of ServiceStack (v3.9.34).

    Existing behavior

    RegisterAs is an Autowired API, i.e:

    Container.RegisterAs<ConcreteDownloadServices, IDownloadServices>();
    

    This tells ServiceStack’s IOC to populate every public property with dependencies resolved by the IOC. Which because it is a string public property will try to resolve the registered string from the IOC. In code terms, this is happening under the hood:

    new ConcreteDownloadServices { 
        ArbitraryProperty = Container.TryResolve<string>()
    };
    

    Which because you don’t have any “string” registered will override the property with null. Only public properties are auto-wired so you can avoid this behavior by changing it to an protected, private or internal property.

    Otherwise you can override the default IOC behavior by registering a custom delegate factory which gives you full control over the construction of your dependency, e.g:

    container.Register<IDownloadServices>(c => new ConcreteDownloadServices());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Data Service created using WCF that internally uses nHibernate. This WCF
have created REST service using servicestack and in post request I have return object
I have built a service with ServiceStack (customer example) as per this link: https://docs.google.com/present/view?id=dg3mcfb_213gsvvmmfk
I have created service to get the country details information of various clients, but
So I have this Windows service created in VB.Net, and all it does is
I have constructed a simple Rest service using ServiceStack (which is brilliant), that returns
I have a web service created using Apache CXF, and two .NET clients using
I have created a simple silverlight application using WCF service.. My service created well
In order to decouple code you can have service locater's but is this not
I have an OData WCF ADO.NET service created with Entity Framework using protocol version

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.