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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:27:23+00:00 2026-06-15T17:27:23+00:00

I have a DevExpress example mvc web site application. It use Castle Windsor as

  • 0

I have a DevExpress example mvc web site application. It use Castle Windsor as an IOC. I just tried to replace via Autofac but no luck!

here is the sample code:

container
    .Register(Component
        .For<DbRepositories.ClinicalStudyContext>()
        .LifestylePerWebRequest()
        .DependsOn(new { connectionString }))
    .Register(Component
        .For<DbRepositories.IClinicalStudyContextFactory>()
        .AsFactory())
    .Register(Component
        .For<FirstStartInitializer>()
        .LifestyleTransient())
    .Register(Component
        .For<IUserRepository>()
        .ImplementedBy<DbRepositories.UserRepository>())

and this is my Autofac conversion:

var builder = new ContainerBuilder();

builder.RegisterControllers(typeof(MvcApplication).Assembly);

builder.Register(c => 
    new DbRepositories.AdminContext(connectionString))
    .InstancePerHttpRequest();

builder.RegisterType<DbRepositories.IAdminContextFactory>()
    .As<DbRepositories.IAdminContextFactory>();

builder.RegisterType<DbRepositories.UserRepository>()
    .As<IUserRepository>().InstancePerHttpRequest();

there is no implementetion for AsFactory() on Autofac regarding my research.

this is the IAdminContextFactory interface:

public interface IAdminContextFactory
{
    AdminContext Retrieve();
}

and this is the error application says:

No constructors on type
‘Admin.Infrastructure.EFRepository.IAdminContextFactory’ can be found
with ‘Public binding flags’.

can anyone help?

thanks.

  • 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-15T17:27:23+00:00Added an answer on June 15, 2026 at 5:27 pm

    Your IAdminContextFactory registration will fail, because the first part of the RegisterType must be a service type. In this case, a class that implements the IAdminContextFactory interface. Autofac tries to build an instance of the type, which certainly will fail because you cannot instantiate an interface.

    So, what you need is an implementation of the IAdminContextFactory interface. The Castle AsFactory method generates this implementation for you. You can get this behavior with the Autofac AggregateService extra.

    With the bits in place you can do:

    builder.RegisterAggregateService<IAdminContextFactory>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi, I have tried some diffrent gantt solutions for example Devexpress timelineView but the
I have a DevExpress MVC grid that uses the following .BindToLINQ: .BindToLINQ(typeof(MyContext), Results, ((s,
I have a web project with devexpress component ASPxGridView. So I want to know
Hopefully now I'm posting the right question :) In web application I'm using devexpress
VB .NET 4 WinForms application. I have a (DevExpress) grid bound to an IEnumerable(Of
I have made use of the DevExpress ASPxDropDownEdit and DropDownWindowTemplate. I have copied the
I have two Devexpress gridview in a page. I tried binding data to devexpress
I have a Devexpress textEdit control in windows application. Do we have option to
I have to use DevExpress's Xtra Reports which is in a third-part app. I
I have just started using the <% Html.DevExpress().DateEdit() control and i got it to

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.