Oct 9 2006

WCF services hosted in IIS

Category: IT Related | .NetRory Primrose @ 17:02

Today I have been playing with a WCF service hosted in IIS. Previously, I have always used the self-hosted services running from a console application.

I am having issues with IIS hosting because although the service code is running correctly, the client is throwing a response error because the connection with the server is being unexpectedly closed. Still haven't figured this one out.

Tonight, I have been doing a little bit of reading about this topic and came across this interesting note from the Hosting Services page in the SDK.

The message-based activation provided for an WCF service by IIS 5.1 on Windows XP blocks any other self-hosted WCF service on the same box from using port 80 to communicate.

The Hosting Services page is a great reference for helping you to figure out the best way of hosting your WCF service. Windows Activation Service seems like the most comprehensive hosting solution, but obviously requires Vista as the platform.

Tags:

Comments (7) -

1.
Rory Primrose Rory Primrose says:

The exception is question is this:

An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

Additional information: The underlying connection was closed: The connection was closed unexpectedly.

Anyone got any pointers?

2.
Rory Primrose Rory Primrose says:

The problem was that because I was using contracts defined in assemblies rather than a WSDL setup, my data contracts were not assigned for the non-primitive values being returned from the service. In this case, I was returning a list of a concrete type, but the type wasn't defined in the contract.

3.
Rajiv Rajiv says:

Hi rory,
I have some custom collection object marked with DataContract and when I try to get it through the service at client, it throws the same error that you mentioned. I can see my service filling up custom collection object but then when it goes to the first element of that collection and tries to read the property value, it throws same exception.

Any clues?

4.
Rory Primrose Rory Primrose says:

Hi Rajiv,

Just to clarify, when you read the first element and an exception is thrown, is that still in the server code or the client code? What kind of class/interface does your custom collection use?

5.
Rajiv Rajiv says:

Hi rory,
Thanks for prompt help.

It throws exception in server code and bubbles up at client side.
My custom collection has [CollectionDataContract] attribute and it inherits BindingList and implement IRaiseItemChangedEvents, where T is my custom object.

Thanks
Rajiv

6.
Rory Primrose Rory Primrose says:

Try turning on tracing and logging on both the server and client. Use the trace viewer in the SDK to read the entries. That might give some background info. The other thing to try is turning on the server config that allows detailed exception information to be passed back to the client.

7.
Rajiv Rajiv says:

Thanks for your help.

Tracing and logging really helped. I used WCF sdk tools (viewer and editor for config). I see that I was trying to serialize bitmap property of my object which it was not allowing and somehow gave me the "connection closed" error. Now, I have to find a way to serialize an image field for my object.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading