簡體   English   中英

Nancy - 來自其他程序集的嵌入式視圖

[英]Nancy - embedded views from other assembly

我創建了2個項目:

  1. 文件Views \\ other.html的類庫設置為嵌入式資源。

  2. 具有Nancy自托管設置,引導程序和南希模塊的控制台應用程序,它通過返回名為“other.html”的視圖(在另一個程序集中定義的視圖)簡單地響應GET。

Bootstrapper配置:

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)的行時,app無法啟動以下錯誤:

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.

我在這里錯過了什么?

問題已解決: https//groups.google.com/forum/#!topic / nancy- web-framework / 9N4f6-Y4dNA

看起來目前可用的Nuget包不包含此修復!!!

我反編譯0.22 nuget包,對我來說這個改變不存在。 它在github上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM