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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:16:55+00:00 2026-06-10T13:16:55+00:00

I am creating a website using Orchard CMS and I have an external .NET

  • 0

I am creating a website using Orchard CMS and I have an external .NET project written with Ninject for dependency injection which I would like to use together with a module within Orchard CMS. I know that Orchard uses Autofac for dependency injection and this is causing me problems since I never worked with DI before.

I have created an Autofac module, UserModule, which registers the a source, UserRegistrationSource, like this:

UserModule.cs

public class UserModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder.RegisterSource(new UserRegistrationSource());
    }
}

UserRegistrationSource.cs

public class UserRegistrationSource : IRegistrationSource
{
    public bool IsAdapterForIndividualComponents
    {
        get { return false; }
    }

    public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
    {
        var serviceWithType = service as IServiceWithType;
        if (serviceWithType == null)
            yield break;

        var serviceType = serviceWithType.ServiceType;
        if (!serviceType.IsInterface || !typeof(IUserServices).IsAssignableFrom(serviceType) || serviceType != typeof(IUserServices))
            yield break;

        var registrationBuilder = // something...

        yield return registrationBuilder.CreateRegistration();
    }
}

UserServices.cs

public interface IUserServices : IDependency
{
    void Add(string email, string password);
}

public class UserServices : IUserServices
{
    private readonly EFMembershipManager _manager;

    public UserServices(EFMembershipManager manager)
    {
        _manager = manager;
    }

    public void Add(string email, string password)
    {
        _manager.createUser(email, password);
    }
}

EFMembershipManager.cs constructor

public EFMembershipManager(ServerRepository db,
                           ServerRepositoryMembershipProvider membershipProvider,
                           string testUsername,
                           string serverUsername)
{
...
}

EFMembershipManager is a class from the external project which uses Ninject for DI’s and uses ServerRepository and ServerRepositoryMembershipProvider whom also are injected using Ninject.

And now I’m stuck…

Should UserRegistrationSource take the Ninject container (kernel) as a constructor argument and try to find the IUserServices service and then mediate the resolves to the Ninject kernel and return an empty Enumerable so that Autofac doesn’t try to resolve anything related to IUserServices or is this the wrong approach?

  • 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-10T13:16:56+00:00Added an answer on June 10, 2026 at 1:16 pm

    Autofac supports registration sources (and more on registration sources here). A registration source is a service that the container will consult when trying to resolve a type. The source can respond, either with a means to build the type, or an empty list which indicates that the source is not able to provide the requested type.

    In your case, a registration source could be implemented that will try to resolve the requested type from your Ninject container.

    I’m not too familiar with Orchard but I’m guessing that it uses configuration files to configure Autofac. My suggestion is that you create a simple Autofac module that registers your registration source implementation, and that you configure Orchard to load the module from config.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a website using JavaScript/ASP.NET/C#/CSS/HTML/Compact SQL server. I have the majority of
When creating a website using Asp.Net and using controls such as the ListView is
I am creating a website using ASP.NET that supports multiple languages. For that I
i'm creating a shopping website that will sell computer parts using MVP and asp.net.
I'm creating .net websites against a CMS server using the API of the software
I am in the process of creating a website using ASP.NET MVC. I went
I'm creating an events website using PHP. I have a database with an events
Summary: I have an ASP.NET MVC website in IIS named 'Website' using an AppPool
I am creating a website using master page, which works fine. but after I
I am creating a Mobile website using Asp.net and i am facing a XML

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.