4

I need to write an extensible ASP.NET MVC 3 application, while an extension is a .dll with a very specific purpose (i.e: a forum extension, a blog extension, a wiki extension, etc).

An extension wouldn't have any views though, which should make this process much simpler. It should only has controllers and a few models.

I've been thinking about implementing this with MVC areas, and load them like so:

// Global.asax

public static void PreApplicationStartMethod()
{
    foreach (var file in Directory.GetFiles(
        Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions/"), "*.dll"))
    {
        BuildManager.AddReferencedAssembly(Assembly.LoadFile(file));
    }
}

protected void Application_Start()
{       
    AreaRegistration.RegisterAllAreas();
    ...
}

Now this worked perfectly, but still, it seems like a pretty old and static way... .NET 4 has Managed Extensibility Framework. MVC 3 has Dependency Injection.

I've read about Portable Areas and SharpArchitecture. I was trying to understand the Orchard plugin framework both from the source code and the documentation. But still I'm not sure what should I use.

To make my question more practical - how would you include Controllers and Models from an external project to the main MVC web application? What is the best way to do this? Should I use Dependency Injection here?

Thanks.

1
  • someone recently told me that link only answers are frowned upon in this community. somehow, I find that contradictory enough. Commented Mar 23, 2012 at 10:32

1 Answer 1

1

I've had a look at this previously, let me know if these help:

  1. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part One
  2. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Two
  3. Modular ASP.NET MVC using the Managed Extensibility Framework (MEF), Part Three
  4. MVC3 and MEF
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.