New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register and resolving classes with primitive parameters #605

vkg-mca opened this Issue Aug 10, 2018 · 1 comment


2 participants

vkg-mca commented Aug 10, 2018

I am using Simple Injector version 4.3.0. and have a problem where I want to register a class with single constructor having three string parameters, but parameter values are not known until runtime. So my problem is


private Container container = new Container();
container.RegisterSingleton<IEventHubConfiguration, EventHubConfiguration>();

Class has three parameters


public class EventHubConfiguration : IEventHubConfiguration
    public EventHubConfiguration(string key, string value, string account)
        //Some code here


In Step#1, I cannot register the class as it is asking for all three parameters to be passed. I can NOT pass the parameter values because these are NOT known yet. I can pass hardcoded values during registration and update them back when get the actual values but not sure if this is right solution.

@dotnetjunkie dotnetjunkie changed the title from Resgistering and resolving classes with primitive parameters to Register and resolving classes with primitive parameters Aug 10, 2018


This comment has been minimized.


dotnetjunkie commented Aug 10, 2018

You'll find the source of your trouble and the solution in the article Dependency-injection Code Smell: Injecting runtime data into components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment