title: Locate Razor Pages in another assembly
body: <p>I want to locate My Project Razor Pages in another assembly. 
  for doing this I write following code:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      var adminAssembly = Assembly.Load(new AssemblyName("App"));
      services.AddMvc().AddApplicationPart(adminAssembly).AddRazorOptions(options =&gt;
      {
          var previous = options.CompilationCallback;
          options.CompilationCallback = context =&gt;
          {
              previous?.Invoke(context);
  
              context.Compilation = context.Compilation.AddReferences(
                  MetadataReference.CreateFromFile(typeof(dodo).Assembly.Location));
          };
      });
  
      services.Configure&lt;RazorViewEngineOptions&gt;(options =&gt;
      {
          options.FileProviders.Add(new EmbeddedFileProvider(Assembly.Load("App")));
          options.FileProviders.Add(new PhysicalFileProvider(@"C:\Users\soheil\Documents\Visual Studio 2017\Projects\WebApplication5\App"));
      });
  }
  </code></pre>
  
  <p><strong>my solution:</strong></p>
  
  <p><img src="https://user-images.githubusercontent.com/22220356/31394411-1c2d5ed0-adeb-11e7-9cfb-c5ce7f903d05.png" alt="devenv_2017-10-10_18-44-26"></p>
  
  <p>when running <code>localhost:5000/SameTodo</code> Get Following Error:</p>
  
  <blockquote>
    <p>One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.</p>
  </blockquote>
  
  <p>stack:</p>
  
  <blockquote>
    <p>The type or namespace name 'SameTodoModel' could not be found (are you
    missing a using directive or an assembly reference?)
    +
            public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper
    Html { get; private set; } The type or namespace name 'SameTodoModel'
    could not be found (are you missing a using directive or an assembly
    reference?)
    +
            public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
    ViewData =>
    (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData;
    The type or namespace name 'SameTodoModel' could not be found (are you
    missing a using directive or an assembly reference?)
    +
            public SameTodoModel Model => ViewData.Model; The type or namespace name 'SameTodoModel' could not be found (are you missing a
    using directive or an assembly reference?)
    +
            public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
    ViewData =>
    (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)PageContext?.ViewData;</p>
  </blockquote>
  
  <p>and set <code>PreserveCompilationContext</code> to false but now worked how can I solve this problem?</p>