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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:56:05+00:00 2026-05-24T19:56:05+00:00

I have the following type which I need to be instantiated by StructureMap: public

  • 0

I have the following type which I need to be instantiated by StructureMap:

public class AWebService : IAWebService
{
    private readonly string _applicationId;
    private readonly string _username;
    private readonly string _password;

    public AWebService(string applicationId, string username, string password)
    {
        _applicationId = applicationId;
        _username = username;
        _password = password;
    }
}

The problem is that this constructor takes 3 parameters. I’ve seen examples how to provide StructureMap with one parameter (e.g. Passing constructor arguments when using StructureMap) but I’m not sure what I need to do to pass 3 in.

Is it simply a case of:

For<IAWebService>().Use<AWebService>()
  .Ctor<string>("applicationId").Is(GetIDFromConfig())
  .Ctor<string>("username").Is(GetUsernameFromConfig())
  .Ctor<string>("password").Is(GetPasswordFromConfig());

or do I have to configure it differently?

  • 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-24T19:56:08+00:00Added an answer on May 24, 2026 at 7:56 pm

    Have you tried the code in your question, it looks correct.

    Register your type with structuremap and set the string constructor parameters

    var container = new Container(x => {
                x.For<IAWebService>().Use<AWebService>()
                    .Ctor<string>("applicationId").Is("my app id")
                    .Ctor<string>("username").Is("my username")
                    .Ctor<string>("password").Is("my passowrd");
            });
    

    Then you can get your service with the parameters set.

    var service = container.GetInstance<IAWebService>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in Drupal 6: A Master CCK type which contains a
I have the following code: Type type = typeof(T); foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public
I have a DbContext with several of the following type of members: public DbSet<JobLevel>
I have following complex query which I need to use. When I run it,
I have the following script which I need to modify a little. Here is
I have the following: typeof(Action<User, Int32>) which I need to be able to create
I have following string. DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) Key: a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO I
I have the following linq query which returns a Report Object; yet I need
i have one jquery function which i need to work in following way 1.
I have to create the following type of HTML structure: <div id=dcontent> <ul class=thm>

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.