简体   繁体   中英

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. I can build fine, but when I return anything via GenericFileRespose, I get:

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.

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. Everything is built for "any 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.

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. JsonNetBodyDeserializer.Deserialize() references BindingContext.ValidModelProperties, but this does not exist in the Nancy 0.23.2 source; it has been replaced by BindingContext.ValidModelBindingMembers (which includes properties and fields).

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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