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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:51:11+00:00 2026-05-23T11:51:11+00:00

I’m designing a plugin framework for ASP.NET MVC3 using Razor views, and I’m having

  • 0

I’m designing a plugin framework for ASP.NET MVC3 using Razor views, and I’m having an issue getting the embedded views to work correctly.

The plugin framework is designed to have these features:

  • Each plugin has its own models, controllers and views. The views are embedded resources, and the controllers derive from a PluginController class
  • The plugins have dependency references to a shared class library that defines the PluginController base class
  • The “shell” web application that hosts the plugins must not hold references to any plugins at design time, since it does not know at design time which plugins it has.
  • The plugin dll’s are dropped in a folder in the shell application, which is not the /bin folder
  • The shell takes care of:
    1. Discovering the plugins (using reflection)
    2. Registering all controllers (I’m using Spring.Net for this)
    3. Creating routes to the controllers
    4. Serving the razor files (cshtml) through a custom VirtualPathProvider

Now everything works fine, except when the embedded views have references to types within the plugin dll. Then I get the infamous error (names left out):

The type or namespace name '[Plugins]' does not exist in the namespace '[MyPluginSolution]' (are you missing an assembly reference?)

The reason for this is that the csc compiler which is invoked runtime to compile the razor views only get the dll references from the bin folder and the GAC.

I’ve also tried pre-compiling the views using this technique but in the end it gives the same results, since the runtime insists on compiling a wrapper for the pre-compiled razor view.

I could of course drop the plugin dll in the /bin folder, but my question is:

Is there a way to register dlls in a non-bin (and non-GAC) folder, and treat them as “first class citizens” so they can be used by the razor views?

  • 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-23T11:51:11+00:00Added an answer on May 23, 2026 at 11:51 am

    Ok, the solution was found using this article.

    First I create a class with a PreApplicationStartMethod. This method scans the plugin folder and copies the dlls to the AppDomain.DynamicDirectory.

    Then each of these dll’s are loaded using BuildManager.AddReferencedAssembly.

    And voilà, the strongly-typed Razor views compile beautifully. See the code here:

    [assembly: PreApplicationStartMethod(typeof(MySolution.PluginHandler.PluginActivator), "Initialize")]
    namespace MySolution.PluginHandler
    {
        public class PluginActivator
        {
            private static readonly DirectoryInfo PluginFolderInfo;
    
            static PluginActivator() {
                PluginFolderInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/plugins"));
            }
    
            public static void Initialize() {
                CopyPluginDlls(PluginFolderInfo, AppDomain.CurrentDomain.DynamicDirectory);
                LoadPluginAssemblies(AppDomain.CurrentDomain.DynamicDirectory);
            }
    
            private static void CopyPluginDlls(DirectoryInfo sourceFolder, string destinationFolder)
            {
                foreach (var plug in sourceFolder.GetFiles("*.dll", SearchOption.AllDirectories)) {
                    if (!File.Exists(Path.Combine(destinationFolder, plug.Name))) {
                        File.Copy(plug.FullName, Path.Combine(destinationFolder, plug.Name), false);
                    }
                }
            }
    
            private static void LoadPluginAssemblies(string dynamicDirectory)
            {
                foreach (var plug in Directory.GetFiles(dynamicDirectory, "*.dll", SearchOption.AllDirectories)) {
                    Assembly assembly = Assembly.Load(AssemblyName.GetAssemblyName(plug));
                    BuildManager.AddReferencedAssembly(assembly);
                }
            }
        }
    }
    

    I hope this can help other programmers that want to create a clean plugin framework using these new technologies.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need 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.