Throwing FaultException<T> with custom detail class with is terminating client connection

I'm throwing a FaultException with a custom fault detail class. The classes used in the fault detail are below as is the details of the exception that is received at the client. There are no exceptions on the server side at all... I'm handling all uncaught exceptions when they're thrown in the debugger and WCF doesn't seem to be encountering any... just killing the connection.

The problem seems to be the fact that one of my properties is a collection. If I take the DataMemberAttribute off the property that returns the collection I can throw the fault just fine.

Should I file a bug?

Cheers,
Drew

===== BEGIN CUSTOM FAULT DETAIL CLASSES ====

[DataContract(Name="orderPipelineErrorListFaultDetail", Namespace=http://schemas.mimeo.com/PublicAPI/Ordering/2006/08/01/FaultDetails.xsd)]
publicsealedclass
OrderPipelineErrorListFaultDetail
{
#region
Type specific properties

privateOrderPipelineErrorDetailCollection pipelineErrorDetails =newOrderPipelineErrorDetailCollection();

[DataMember(Name="errors")]
publicOrderPipelineErrorDetailCollection
PipelineErrorDetails
{
get
{
returnthis
.pipelineErrorDetails;
}
}

#endregion
}

[CollectionDataContract(Name="errors",ItemName="error",Namespace=http://schemas.mimeo.com/PublicAPI/Ordering/2006/08/01/FaultDetails.xsd)]
publicsealedclassOrderPipelineErrorDetailCollection :List<OrderPipelineErrorDetail
>
{
}

[DataContract(Name="error", Namespace=http://schemas.mimeo.com/PublicAPI/Ordering/2006/08/01/FaultDetails.xsd)]
publicsealedclass
OrderPipelineErrorDetail
{
#region
Constructors

public
OrderPipelineErrorDetail()
{
}

public OrderPipelineErrorDetail(string typeName,string
message)
{
this
.typeName = typeName;
this
.message = message;
}

#endregion

#region
Type specific properties

privatestring typeName;

[DataMember(Name="typeName")]
publicstring
TypeName
{
get
{
returnthis
.typeName;
}

set
{
if(value ==null
)
{
thrownewArgumentNullException
();
}

this.typeName =value
;
}
}

privatestring
message;

[DataMember(Name="message"
)]
publicstring
Message
{
get
{
returnthis
.message;
}

set
{
if(value ==null
)
{
thrownewArgumentNullException
();
}

this.message =value
;
}
}

#endregion
}

===== BEGIN EXCEPTION MESSAGE AND STACK TRACE ====

Test method Tests.OrderingServiceTest.GetQuoteWithMissingAddressPostalCode threw exception System.ServiceModel.CommunicationException, but exception System.ServiceModel.FaultException`1[[Mimeo.WebServices.PublicAPI.Ordering.OrderPipelineErrorListFaultDetail, Mimeo.OrderingWebServiceContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] was expected. Exception message: System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. > System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.

at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
End of inner exception stack trace

Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Mimeo.WebServices.PublicAPI.Ordering.OrderingServiceContract.GetQuote(QuoteRequestMessage request)
at Tests.OrderingServiceTest.GetQuoteWithMissingAddressPostalCode() in D:\Drew's Documents\TFVC Root\Public Web Service APIs\Main\Ordering Web Service\Tests\Unit Tests\OrderingServiceTests.cs:line 317

[11821 byte] By [DrewMarsh] at [2007-12-24]
# 1

Hmmm... very strange. Having not received a response to this post I went back to tinkering to see if I could figure out what the problem was. Well, last week I was getting that useless "connection closed" problem, but today when I ran it I got an exception on the server side with the information that I needed.

The problem is, if you look back at my property that exposes the collection, I don't have a setter. Well that's exactly what the exception told me today. So, I implemented the setter and it works:

[DataMember(Name="errors")]
public OrderPipelineErrorDetailCollection
PipelineErrorDetails
{
get
{
return this
.pipelineErrorDetails;
}

set
{
this
.pipelineErrorDetails = value;
}
}

In XML serialization (which is what I'd most definitely prefer to use, but for some reason I'm forced to use DataContractSerializer for faults), you don't need a setter for the collection properties. Rather it assumes it can pull the instance of the collection off of the property and just add to it. It seems like DataContractSerializer wants to instantiate the collection itself and set the property. *sigh*

DrewMarsh at 2007-10-8 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified