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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:27:22+00:00 2026-06-14T05:27:22+00:00

I have the following constructors: public ReferenceService( IAzureTable<Reference> referenceRepository) { _referenceRepository = referenceRepository; }

  • 0

I have the following constructors:

public ReferenceService(
    IAzureTable<Reference> referenceRepository)
{
    _referenceRepository = referenceRepository;
}

public ReferenceService(CloudStorageAccount devStorageAccount)
{
    _referenceRepository = new AzureTable<Reference>(devStorageAccount, "TestReferences");
}

and in Bootstrapper.cs

CloudStorageAccount storageAccount;
        storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
        var container = new UnityContainer();
        container.RegisterType<IReferenceService, ReferenceService>();

When I try to have Unity resolve my service it gives me an error message saying there’s more than one constructor with one parameter:

[ResolutionFailedException: Resolution of the dependency failed, type = "WebUx.xController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type ReferenceService has multiple constructors of length 1. Unable to disambiguate.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving WebUx.xController,(none)
  Resolving parameter "referenceService" of constructor WebUx.xController(
Storage.Services.IContentService contentService,  
Storage.Services.IReferenceService referenceService
)
    Resolving Storage.Services.ReferenceService,(none) (mapped from Storage.Services.IReferenceService, (none))
]

Is there a way I can force Unity to use one of my two constructors?

  • 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-14T05:27:24+00:00Added an answer on June 14, 2026 at 5:27 am

    One way is to annotate the constructor you want with an InjectionConstructorAttribute:

    When a target class contains more than one constructor with the same number of parameters, you must apply the InjectionConstructor attribute to the constructor

    Sample:

    [InjectionConstructor]
    public ReferenceService(IAzureTable<Reference> referenceRepository)
    {
        _referenceRepository = referenceRepository;
    }
    
    public ReferenceService(CloudStorageAccount devStorageAccount)
    {
        _referenceRepository = new AzureTable<Reference>(devStorageAccount, "TestReferences");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following type being registered in Unity: container.RegisterType<IAzureTable<Account>, AzureTable<Account>>(); The definition and
I have a service with an following constructor: public ShimmerService(Context context, Handler handler) {
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have the following two constructors in my base class: protected ExternalSystemException( params Object[]
We have the following class hierarchy: public interface IManager { object GetObject(int); } public
I have been sharing database variables using the following code: Namespace DataAccessVariables Public Class
The RoutedCommand in WPF has 3 overloaded constructors. Consider the following: public static RoutedCommand
I have a custom view that extends LinearLayout, with these constructors: public class CustomView
I have the following java class: package domain; //imports @Entity public class User {
I'm totally new to C# generic so I have the following problem. I have

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.