2014-04-14 28 views
3

嵌入式意見我已經創建了2個項目:南希 - 從其他裝配

  1. 類庫與文件瀏覽\ other.html設置爲嵌入的資源。

  2. 控制檯應用程序與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. 

缺少什麼我在這裏?

回答