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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:06:14+00:00 2026-06-04T00:06:14+00:00

Is it possible to group components’ registrations by name using autofac ? For instance,

  • 0

Is it possible to group components’ registrations by name using autofac?
For instance, the bellow code has two registrations for IDbContextProvider.
And I want WfcService to resolve only a named instance (“proxyless”) of IDbContextProvider.
I’d like to use something like DependsOnNamed(“proxyless”) method to explicitly set a dependency on a set of named instances that have the same name.

I want the whole system to use the default implementation of IDbContextProvider while successors of IWfcService should use their own named instances.

var builder = new ContainerBuilder();
builder.RegisterType<DbContextProvider>().As<IDbContextProvider>().As<IDbContextProvider>();
builder.RegisterType<ProxyLessDbContextProvider>().Named<IDbContextProvider>("proxyless");

builder.RegisterType<Repository>().As<IRepository>();//depends on IDbContextProvider 
builder.RegisterType<BusinessService>().As<IBusinessService>();//depends on IRepository

builder.RegisterType<WfcService>().As<IWfcService>().DependsOnNamed("proxyless");//depends on IBusinessService

IContainer container = builder.Build();

var wcf = container.Resolve<IWfcService>(); // should depend on "proxyless" IDbContextProvider
  • 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-04T00:06:16+00:00Added an answer on June 4, 2026 at 12:06 am

    The most appropriate way to achieve described behavior is to use the separate scope with overridden registration. If you want to override a registration for WCF services you should

    var _wcfScope = _container.BeginLifetimeScope(b=> 
    {
        b.RegisterType<NewDbContextProvider>().As<DbContextProvider>();
        //put wcf services registration here because of the issue http://code.google.com/p/autofac/issues/detail?id=365
    });
    AutofacHostFactory.Container = _wcfScope;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to group in jqgrid without using subgrids ? I just want
Possible Duplicate: Retrieving the last record in each group I have two tables set
Is it possible to apply (and remove) Windows group policy settings using .NET? I
Normally HTML check boxes are grouped based on name. Is it possible to group
I have a set of values, each value has a possible group. The value
Is it possible to group by distance using the geokit-rails gem for ActiveRecord? Say
Possible Duplicate: mysql: Using LIMIT within GROUP BY to get N results per group?
Possible Duplicate: Group files in Visual Studio The problem is, that I want to
I'm trying to come up with the largest possible group of friends that would
It is possible to group some fields in the edit form? I would like

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.