【问题标题】:Nancy self hosting HttpListenerException: "The parameter is incorrect"Nancy 自托管 HttpListenerException:“参数不正确”
【发布时间】:2015-01-08 09:37:50
【问题描述】:

我通过 github 安装了 NancyFX 0.23.2 源代码,并在 Windows 7 x64 上使用 VS2013 Pro 进行构建。我可以很好地构建,但是当我通过 GenericFileRespose 返回 anything 时,我得到:

A first chance exception of type 'System.Net.HttpListenerException' occurred in System.dll
---
System.Net.HttpListenerException (0x80004005): The parameter is incorrect
   at System.Net.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
   at Nancy.Responses.GenericFileResponse.<>c__DisplayClass1.<GetFileContent>b__0(Stream stream) in h:\home\projects\nancy\0.23.2\Nancy\src\Nancy\Responses\GenericFileResponse.cs:line 82
   at Nancy.Hosting.Self.NancyHost.OutputWithDefaultTransferEncoding(Response nancyResponse, HttpListenerResponse response) in h:\home\projects\nancy\0.23.2\Nancy\src\Nancy.Hosting.Self\NancyHost.cs:line 320
   at Nancy.Hosting.Self.NancyHost.ConvertNancyResponseToResponse(Response nancyResponse, 
...

如果我链接到通过 nuget 检索到的 Nancy 二进制文件,我的输出很好,但我没有 Nancy 的调试信息。

我启动了 Nancy 自我托管演示,它似乎运行良好,但如果我能说出我的项目有什么不同的话,我就冒险了。一切都是为“任何 cpu”而构建的。 Nancy 是使用目标 .net 4.0 客户端配置文件构建的,Nancy.Hosting.Self 目标是完整的 .net 4.0,我的类库和启动 NancyHost 的控制台应用程序也是如此。

任何见解将不胜感激。

【问题讨论】:

    标签: c# nancy self-hosting


    【解决方案1】:

    我也可以回答这个问题,因为没有其他人回答过。

    一定有一些问题,当我安装 Nancy.Serialization.JsonNet 0.23.2 的源代码时,它与我通过 nuget 获得的 Nancy 0.23.2 一起工作,但不是来自 github 的 Nancy 0.23.2 源代码。 JsonNetBodyDeserializer.Deserialize() 引用了 BindingContext.ValidModelProperties,但这在 Nancy 0.23.2 源码中不存在;它已被 BindingContext.ValidModelBindingMembers(包括属性和字段)取代。

    当我检索、编译和使用 Nancy 0.23.1 的源代码时,Nancy.Serialization.JsonNet 很高兴,并且我的 System.Net.HttpListener 异常消失了。

    所以,我的解决方案是使用 Nancy 0.23.1,但我仍然不知道为什么 0.23.2 不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      相关资源
      最近更新 更多