3
嵌入式意见我已经创建了2个项目:南希 - 从其他装配
类库与文件浏览\ other.html设置为嵌入的资源。
控制台应用程序与Nancy自托管设置,引导程序和南希模块,通过返回一个名为“other.html” - 在另一个程序集中定义的视图简单地响应GET。
引导程序配置:
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
ResourceViewLocationProvider.RootNamespaces.Add(GetType().Assembly, "ConsoleApplication1.Views"); // (1)
ResourceViewLocationProvider.RootNamespaces.Add(typeof(Class1).Assembly, "ClassLibrary1.Views");
}
protected override NancyInternalConfiguration InternalConfiguration
{
get { return NancyInternalConfiguration.WithOverrides(OnConfigurationBuilder); }
}
private void OnConfigurationBuilder(NancyInternalConfiguration x)
{
x.ViewLocationProvider = typeof(ResourceViewLocationProvider);
}
应用此配置正常启动,但它未能恢复其定义为其他库的嵌入式资源“other.html”。
当我返回嵌入主控制台应用程序中的视图时,它可以正常工作。
当我删除标记为(1),然后应用程序无法启动并出现以下错误行:
Unable to resolve type: Nancy.ViewEngines.ViewEngineApplicationStartup
Only one view was found in assembly ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, but no rootnamespace had been registered.
缺少什么我在这里?