asp.net mvc - Strongly typed Razor views in dynamically loaded assembly don't compile at runtime -


I have an MVC 3 area in an assembly that is loaded dynamically With MEF
If I use the Web Form View engine with the typed sequence, everything works fine.
If I use the Ranger View engine with a dynamic model, then it works fine.

But if I use strongly typed razor view , the scene fails in a compiling order.

The problem is that the Dynamically Loaded Assembly is not in the list of referenced assemblies sent to C #.

The generated C # code looks like this:

  namespace ASP {using the system; / * Other namespace * / Public class _Page_MyApp_Views_Home_Index_cshtml: System. Web. MVC WebViews & lt; MyApp.ViewModels.Search.IndexViewModel & gt; Here is an error message:  
  Compiler Error Message: CS0246: Type or namespace name 'MyApp' ( Do not you remember the use director or assembly reference?)   

Do you have any ideas, why it works with the webform visual engine, but not with the razor ? What is a way to tell the compiler to use my Dynamic Load Assembly for the compiler?

Thanks

Where are you loading your assemblies? Usually (as discussed in my blog) If you are not loading your conventions from the / bin directory, you will need to make sure that the path of the assemblies can be searched. The way I have done this before, it is used by AppDomain.CurrentDomain.AppendPrivatePath (path) . Although this is an excluded method, you are not creating AppDomain yourselfself (IIS worker process when hosting your app), you can also use it to update the current domain to use here. Now that an assembly is being resolved, if it is not a GAC, then AppDomain will search for private routes for the assembly.

Why does this work for the webform against the razor, we will need to know more about your project architecture.

Comments