【问题标题】:Nancy website and Nancy wcf host in different projectsNancy 网站和 Nancy wcf 托管在不同的项目中
【发布时间】:2012-11-02 22:58:27
【问题描述】:

我希望在一个 VS 项目和托管此网站的 WCF 服务的专用项目中拥有具有 Nancy.Hosting.Aspnet 依赖项的 Nancy 支持的网站。测试性能背后的想法并有能力选择使用 IIS 或我自己的服务。

对于 WCF 项目的引用,我添加了网站项目。怎么可能以这种方式接待南希?

如何告诉 Nancy 不在当前可执行文件中搜索模块,而是在附加到它的 DLL 中搜索模块?应该满足什么条件?目前最好的猜测是让命名空间同意,但目前还没有运气。如果这里有帮助的话,是我用来从 WCF 可执行文件运行 Nancy 的代码(它是标准的):

class Program
{
    private static readonly Uri BaseUri = new Uri("http://localhost:1234/");

    static void Main(string[] args)
    {
        AppDomainAssemblyTypeScanner.LoadAssemblies("Basta.dll");

        using (CreateAndOpenWebServiceHost())
        {
            Console.WriteLine("Service is now running on: {0}", BaseUri);
            Console.ReadLine();
        }
    }

    private static WebServiceHost CreateAndOpenWebServiceHost()
    {
        var host = new WebServiceHost(
            new NancyWcfGenericService(new Basta.Bootstrapper()),
            BaseUri);

        host.AddServiceEndpoint(typeof(NancyWcfGenericService), new WebHttpBinding(), "");
        host.Open();

        return host;
    }
}

我使用了来自this question 的方法(通过调用AppDomainAssemblyTypeScanner.LoadAssemblies),但没有奏效,很遗憾。

【问题讨论】:

    标签: .net wcf nancy


    【解决方案1】:

    我找到了原因。当 Nancy 作为 WCF 运行时,通常在 IIS 虚拟文件夹中处理的所有外部资源都变得不可用。这意味着没有模板、没有样式、没有 javascript。什么都没有。

    因此,要解决此问题,需要将所有其他资源复制到输出文件夹(在每个文件的 Visual Studio 属性中都有一个选项)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-05
      相关资源
      最近更新 更多