简体   繁体   English

Nancy自托管HttpListenerException:“参数不正确”

[英]Nancy self hosting HttpListenerException: “The parameter is incorrect”

I installed NancyFX 0.23.2 source via github and am building with VS2013 Pro on Windows 7 x64. 我通过github安装了NancyFX 0.23.2源,并在Windows 7 x64上使用VS2013 Pro进行了构建。 I can build fine, but when I return anything via GenericFileRespose, I get: 我可以构建良好,但是当我通过GenericFileRespose返回任何内容时,我得到:

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, 
...

If I link, instead, to Nancy binaries retrieved via nuget, my output is fine, but I have no debugging info for Nancy. 如果我链接到通过nuget检索到的Nancy二进制文件,我的输出很好,但是我没有Nancy的调试信息。

I fired up the Nancy self host demo and it seemed to work fine, but danged if I can tell what is different about my project. 我启动了Nancy自托管演示程序,它似乎运行良好,但如果我不能说出我的项目有什么不同之处,就会感到不满意。 Everything is built for "any cpu". 一切都是为“任何CPU”构建的。 Nancy is built with a target .net 4.0 client profile, Nancy.Hosting.Self target is .net 4.0 full, as is my class library and my console app that fires up the NancyHost. Nancy使用目标.net 4.0客户端配置文件Nancy.Hosting.Self目标构建为.net 4.0完整版,我的类库和启动NancyHost的控制台应用程序也是如此。

Any insight would be greatly appreciated. 任何见识将不胜感激。

I may as well answer the question since no one else did. 我最好回答这个问题,因为没有人做过。

There must be something a bit fishy, as when I installed source for Nancy.Serialization.JsonNet 0.23.2, it worked with the Nancy 0.23.2 I got via nuget, but not the Nancy 0.23.2 source from github. 一定有些麻烦,例如,当我安装Nancy.Serialization.JsonNet 0.23.2的源代码时,它与我通过nuget获得的Nancy 0.23.2一起工作,但不适用于来自github的Nancy 0.23.2源。 JsonNetBodyDeserializer.Deserialize() references BindingContext.ValidModelProperties, but this does not exist in the Nancy 0.23.2 source; JsonNetBodyDeserializer.Deserialize()引用BindingContext.ValidModelProperties,但这在Nancy 0.23.2源代码中不存在;参见参考资料。 it has been replaced by BindingContext.ValidModelBindingMembers (which includes properties and fields). 它已由BindingContext.ValidModelBindingMembers(包括属性和字段)替换。

When I retrieved, compiled, and used the source for Nancy 0.23.1, Nancy.Serialization.JsonNet is happy, and my System.Net.HttpListener exception went away. 当我检索,编译并使用Nancy 0.23.1的源代码时,Nancy.Serialization.JsonNet很高兴,并且我的System.Net.HttpListener异常消失了。

So, the solution for me was to use Nancy 0.23.1, but I still don't know why 0.23.2 doesn't work. 因此,对我来说,解决方案是使用Nancy 0.23.1,但我仍然不知道为什么0.23.2无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM