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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:25:52+00:00 2026-05-18T04:25:52+00:00

I am currently experimenting with dynamically loaded areas with ASP.NET MVC 3 RC. I’ve

  • 0

I am currently experimenting with dynamically loaded areas with ASP.NET MVC 3 RC. I’ve seen it written in many places that this is not what areas are intended for, and (at least pre-MVC 2) not possible, say here for example.

But still! It should be possible to get it to work, right? I’ve created a solution, added a MVC 3 project, added an area and some content. All is working well. Now I created a new class library project (in the same solution), added a reference to it from the MVC-project, and started moving over the area-related parts to the library. Changed the output-directory of the library project to the area-folder of the MVC-project, and made sure the Views and their web.config are copied to the output-folder.

After reading so much about how you couldn’t have external areas, it was a little surprising that this worked. No problem at all really! The problem starts when I remove the reference between the projects, and instead load the library in code. (Before calling AreaRegistration.RegisterAllAreas().) Now it doesn’t work. At all.

I’ve been poking around a bit in the source for MVC 3, and the problem seems to be with BuildManager.GetReferencedAssemblies() which is used to get the assemblies to look for implementations of AreaRegistration.

Now, I’m not 100% sure about this, but it seems as if this method only looks at assemblies that were present/referenced at compile-time, can someone confirm if this is in fact so?

I have debugged through this, and that method-call does indeed not find the assembly I loaded just before the call to it. It might be because of something else that I’ve missed perhaps.. Any ideas?

  • 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-05-18T04:25:52+00:00Added an answer on May 18, 2026 at 4:25 am

    The way things work is a bit complicated.

    GetReferencedAssemblies includes referenced assemblies, not loaded assemblies. This includes:

    • all assemblies referenced in you application’s web.config (such as System.Web.Mvc)
    • everything inherited from root web.config, which includes things like System, System.Web and others that you do not have to add yourself. (You can take a look at the list here: C:\Windows\Microsoft.Net\Framework\v4.0.30319\web.config).
      It also contains a special * item, which:
    • includes everything in your site’s bin folder

    So now take your app v1 (everything in a single app). Everything works because the application code gets compiled into the bin folder which gets automatically included. Also, all of the area views etc are in the application itself so they are accessible.

    Now in app v2 (different project with a proj-to-proj reference and a custom build task that copies the views to the right location in your main app) everything still works, because by default a proj-to-proj references means that the class library binary gets copied to your app’s bin folder. So by the above rules, the area code still gets loaded correctly. The fact that you’ve set the library’s output path to be some location within your main app’s Areas folder does not actually make a difference – you just end up with two copies of the binary.

    Now in app v3 (no proj-proj ref, area library assembly loaded manually) your library assembly gets loaded too late. By the time your code runs the set of referenced assemblies has already been locked and can no longer be changed.

    There is a way to run code and add items to the list of registered assemblies: you can do it using the AddReferencedAssembly method which must be invoked from a PreApplicationStartMethodAttribute method.

    Of course you still have to deal with how you manage your view files. The way you currently have it set up is pretty much the same as having the views in the main application (since they effectively get copied into the right location).

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

Sidebar

Related Questions

I'm currently experimenting with build script, and since I have an ASP.net Web Part
Currently I have an Area in my ASP.NET MVC 2 project call 'API', which
I am currently using/experimenting with autofac as my IoC controller. Previously to this I
currently, when I am experimenting the continuation in functional languages, my understanding is that
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
I currently experimenting with different lightweight text editors for Scala development. jEdit seems to
I'm currently experimenting with loading external SWF files from both an standard AS3 application,
I'm currently experimenting with EJB3 as a prestudy for a major project at work.
I'm currently experimenting with GWT and Spring. More specifically I wanted to make the
I am currently experimenting with the Expression Encoder SDK, but I find it very

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.