다른 어셈블리에서 내 프로젝트 레이저 포인터 페이지를 찾고 싶습니다. 이 일을 위해 나는 다음 코드 쓰기 :다른 어셈블리에서 Razor 페이지 찾기
public void ConfigureServices(IServiceCollection services)
{
var adminAssembly = Assembly.Load(new AssemblyName("App"));
services.AddMvc().AddApplicationPart(adminAssembly).AddRazorOptions(options =>
{
var previous = options.CompilationCallback;
options.CompilationCallback = context =>
{
previous?.Invoke(context);
context.Compilation = context.Compilation.AddReferences(
MetadataReference.CreateFromFile(typeof(dodo).Assembly.Location));
};
});
services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(new EmbeddedFileProvider(Assembly.Load("App")));
options.FileProviders.Add(new PhysicalFileProvider(@"C:\Users\soheil\Documents\Visual Studio 2017\Projects\WebApplication5\App"));
});
}
내 솔루션 :
다음과 같은 오류 받기 localhost:5000/SameTodo
을 실행 :
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.
스택 :
,536,913,632을 10The 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;
으로 설정하고 PreserveCompilationContext
을 false로 설정하면 어떻게 작동합니까?이 문제를 해결하려면 어떻게해야합니까?
나는 이것을하지만 작동하지 않습니다. –
어떻게 든 솔루션을 공유해 주실 수 있습니까? Github에 게시하는 것과 같은가? 면도기 뷰에서 사용하고있는 클래스의 네임 스페이스에'using' 지시어가 없을 수도 있습니까? –