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

  • Home
  • SEARCH
  • 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 340389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:36:41+00:00 2026-05-12T10:36:41+00:00

I just started working with dependency injection for the first time and I am

  • 0

I just started working with dependency injection for the first time and I am using as Ninject 2.0 as my IoC container in an ASP.NET MVC 2 website and I’m hitting an activation error that I am not sure how to react to. I am sure it’s simple so hopefully someone can point me in the right direction without too much thought.

I have a property on my class BaseController which takes an IWebsiteSettings and is flagged with the [Inject] attribute. In my StandardKernel I load a module with the following code:

public class WebModule : Module
{
    public override void Load()
    {

        Bind<IWebsiteSettings>()
            .ToProvider(new WebsiteSettingsProvider(WebConfigurationManager.AppSettings))
            .InSingletonScope();

    }
}

public class WebsiteSettingsProvider : Provider<WebsiteSettings>
{
    private const string WebsiteNameKey = "Website.Name";
    private const string ContactFormEmailSubjectKey = "ContactForm.EmailSubject";
    private const string ProductImageDirectoryKey = "Products.ImageDirectory";
    private const string UploadTempDirectoryKey = "Uploads.TempDirectory";

    protected NameValueCollection Settings { get; set; }

    public WebsiteSettingsProvider(NameValueCollection settings)
    {
        Settings = settings;
    }

    protected override WebsiteSettings CreateInstance(IContext context)
    {
        return new WebsiteSettings
                   {
                       WebsiteName = Settings[WebsiteNameKey] ?? string.Empty,
                       ContactFormEmailSubject = Settings[ContactFormEmailSubjectKey] ?? string.Empty,
                       ProductImageDirectory = Settings[ProductImageDirectoryKey] ?? string.Empty,
                       UploadsTemporaryDirectory = Settings[UploadTempDirectoryKey] ?? string.Empty
                   };
    }
}

This is fairly straightforward- I’m trying to load some data from the web.config file and store it in a singleton object for use across my controllers. The call to Bind seems to function exactly as it should and the Settings property in my provider is correctly initialized with the AppSettings collection in the config file. Still, when the application loads the first time:

Server Error in '/' Application.
Error activating SByte* using implicit self-binding of SByte*
No constructor was available to create an instance of the implementation type.

Activation path:
 4) Injection of dependency SByte* into parameter value of constructor of type string
 3) Injection of dependency string into property WebsiteName of type WebsiteSettings
 2) Injection of dependency IWebsiteSettings into property WebsiteSettings of type HomeController
 1) Request for HomeController

Suggestions:
 1) Ensure that the implementation type has a public constructor.
 2) If you have implemented the Singleton pattern, use a binding with InSingletonScope() instead.

Interestingly, if I refresh the page I don’t get the exception and a call to Kernel.Get() returns the correct object.

Any advice?

  • 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-12T10:36:42+00:00Added an answer on May 12, 2026 at 10:36 am

    (We talked about this on IRC, but I’m putting it here in case someone else runs into this problem as well.)

    WebsiteSettings has [Inject] attributes on its properties, so Ninject is trying to resolve a binding from System.String to inject a value into the properties. Since you’re using a custom provider to activate WebsiteSettings instances, you don’t need [Inject] attributes on its properties.

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Edit the .csproj file Remove the processorArchitecture=MSIL on the end… May 12, 2026 at 9:24 pm
  • Editorial Team
    Editorial Team added an answer If you simply do a Calendar.getInstance with the TimeZone argument,… May 12, 2026 at 9:24 pm
  • Editorial Team
    Editorial Team added an answer Its in the 1.4 docs: http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/make_shared.html It appears to have… May 12, 2026 at 9:24 pm

Related Questions

I am just getting started using any DI/IoC toolset and have a very basic
Scenario: The system has number of components, each with its own POM. There are
I just started working with Javascript and I ran into an error with Visual
I just started working for the first time with a product that's delivered via

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.