title: ASP.NET MVC 3 - Portable Area View doesn't find my model
body: <p>I've started using MvcContrib's Portable Areas and everything works fine for the very simple views, but when I want to use a custom model in my view i get the error saying the namespace doesn't exist.</p>
  
  <p>The view is set to be embedded as resource. And intellisense in the view recognizes the model just fine.</p>
  
  <p>Does anybody have any idea what might cause the problem?</p>
  
  <p><em><strong>UPDATE</em></strong></p>
  
  <p>I think it might have to do with the fact that i'm using MEF to load the plugins. I had a similar problem when loading the controllers. I had to build a custom ControllerFactory that would look in the MEF Controllers list if no suitable controller was found by the default controllerfactory.</p>
  
  <p><em><strong>UPDATE 2</em></strong></p>
  
  <p>I managed to get rid of the error by providing the RazorBuildProvider with my MEF-loaded assemblies. However, now the view is not found anymore. If the view is not strongly typed it IS found.</p>
  
  <pre><code>    RazorBuildProvider.CodeGenerationStarted += (object sender, EventArgs e) =&gt;
      {
          RazorBuildProvider provider = (RazorBuildProvider)sender;
          foreach (var module in ExternalComponents)
          {
              provider.AssemblyBuilder.AddAssemblyReference(module.GetType().Assembly);
          }
      };
  </code></pre>
  
  <p><em><strong>Source Code</em></strong></p>
  
  <p>The Model</p>
  
  <pre><code>namespace Isis.Plugins.TextArea.TextArea.Models
  {
      public class TextAreaModel
      {
          [Required(ErrorMessage = "Field is required")]
          public string Message { get; set; }
      }
  }
  </code></pre>
  
  <p>The Controller:</p>
  
  <pre><code>namespace Isis.Plugins.TextArea.TextArea.Controllers
  {
      [Export(typeof(IController))]
      public class IndexController : Controller
      {
          [HttpGet]
          public ActionResult Index()
          {
              return View(new TextAreaModel() { Message = "Hallow!" });
          }
  
          [HttpGet]
          public ActionResult Editor()
          {
              return View(new TextAreaModel() { Message = "EDITOR CONTENT" });
          }
      }
  }
  </code></pre>
  
  <p>The View</p>
  
  <pre><code>@model Isis.Plugins.TextArea.TextArea.Models.TextAreaModel
  
  @Model.Message
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Compilation Error
  
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
  
  Compiler Error Message: CS0234: The type or namespace name 'Plugins' does not exist in the namespace 'Isis' (are you missing an assembly reference?)
  
  Source Error:
  
  
  Line 27:     
  Line 28:     
  Line 29:     public class _Page_Areas_TextArea_Views_Index_Index_cshtml : System.Web.Mvc.WebViewPage&lt;Isis.Plugins.TextArea.TextArea.Models.TextAreaModel&gt; {
  Line 30:         
  Line 31: #line hidden
  </code></pre>