title: MEF and Razor Views inside Class Library
body: <p>I have a composite ASP .NET MVC 3 Razor application using MEF.  Everything goes fine if I am to deploy plugins as DLL files and views (CSHTML) under the regular <code>Views</code> folder from the application.  But this is not very clean and it won't be a real plugin if I don't place views as embedded resources within the DLL files (along with both controllers and models).</p>
  
  <p>I've followed many articles (most of them are outdated). In fact there is one quite good one here on Stack Overflow: <a href="https://stackoverflow.com/questions/1800387/">Controllers and Views inside a Class Library</a></p>
  
  <p>I've also checked docs for <code>VirtualPathProvider</code> and I've been able to build a custom one that finds the file within the assembly and loads it perfectly (or at least gets the stream to it).  For this I've followed the <code>VirtualPathProvider</code> <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx" rel="nofollow noreferrer">documentation on MSDN</a>.</p>
  
  <p>There is also an implementation for VirtualFile but not yet for VirtualDirectory.</p>
  
  <p>Here is the problem. I'm working with Razor views. I do know that they need config specs from the <code>web.config</code> file for Razor to build them.  But if I embed them within the DLL this config is simply lost.</p>
  
  <p>I wonder if that's why I keep getting the error:</p>
  
  <blockquote>
    <p>The view at '~/Plugins/CRM.Web.Views.CRM.Index.cshtml' must derive
    from WebViewPage, or WebViewPage.</p>
  </blockquote>
  
  <p>Maybe I just need to add some code to make it work? Any ideas?</p>