I have a MVC3 Area in an assembly that is dynamically loaded with MEF.
If I use the Webforms view engine with strongly typed views, everything works fine.
If I use the Razor view engine with a dynamic
model, it works fine too.
But if I use a strongly typed Razor view, the view compilation fail at runtime.
The problem is that the dynamically loaded assembly is not in the list of referenced assemblies passed to the C# compiler.
The generated C# code looks like this:
namespace ASP {
using System;
/* Other namespaces */
public class _Page_MyApp_Views_Home_Index_cshtml
: System.Web.Mvc.WebViewPage<MyApp.ViewModels.Search.IndexViewModel> {
/* Generated code */
}
}
And here is the error message:
Compiler Error Message: CS0246: The type or namespace name 'MyApp' could not be found (are you missing a using directive or an assembly reference?)
Do you have any idea why this works with the Webforms view engine but not with Razor ? Is there a way to tell the compiler to use my dynamically loaded assembly for the compilation ?
Thanks