Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - CommunicationException during deserialization

 
 
Old 04-26-2007   #1 (permalink)
StanB


 
 

CommunicationException during deserialization

I can't figure out why this throws an exception during deserialization:

==============
[DataContract(Namespace = http://OrderEntry)]
public class Order
{
private OrderTypeEnum orderType;

[DataMember]
public OrderTypeEnum OrderType
{
get { return orderType; }
set { orderType = value; }
}
}

[DataContract(Name = "OrderType", Namespace = http://OrderEntry)]
public enum OrderTypeEnum
{

[EnumMember]
Regular = 1,

[EnumMember]
Overnight = 5
}

interface IOrderEntry
{
[OperationContract]
List<Order> GetPreliminary(DateTime dateFrom, DateTime dateTo);
}

========================

When method retuns WCF throws CommunicationException

The problem here is in OrderTypeEnum member, without this member I get no
exception

(I tried KnowType, didn't help)...



My System SpecsSystem Spec
Old 04-26-2007   #2 (permalink)
Marc Gravell


 
 

Re: CommunicationException during deserialization

Just a thought, but you may wish to include a None = 0, or provide a
[DefaultValue]; otherwise orderType will be 0, which can't be
serialized as there is no matching value (they are serialized by name,
not value).

Marc


My System SpecsSystem Spec
Old 04-26-2007   #3 (permalink)
StanB


 
 

Re: CommunicationException during deserialization

That's exactly what it was!

I really appreciate you help, I spent a couple of hours trying to figure it
out, I narrowed it
down to the enum, but did not see that the value was not set... Thank you

Here is the question, though

Why doesn't WCF throws a meaninful exception? CommunictionException?
I understand from the stack trace that the problem was during
deserialization, but
why not just explain that default value is not set and deserialization
failed?

How I am supposed to find the problem? Tracing?

This was really nasty. And this wasn't the first time.

Here is another example:

I added a method to the service contract, updated client, but forgot to
update the server.
Spent two hours trying to find out why I was getting "An unsecured or
incorrecly secured
fault was received other party". It was just a contract mismatch, and had
nothing to do with
WCF internal plumbing, aborting server app domain, etc.

"An usecured or incorrecly secured fault..", go figure...







"Marc Gravell" <marc.gravell@gmail.com> wrote in message
news:%23gmgbAAiHHA.4064@TK2MSFTNGP02.phx.gbl...
> Just a thought, but you may wish to include a None = 0, or provide a
> [DefaultValue]; otherwise orderType will be 0, which can't be serialized
> as there is no matching value (they are serialized by name, not value).
>
> Marc
>



My System SpecsSystem Spec
Old 04-26-2007   #4 (permalink)
Marc Gravell


 
 

Re: CommunicationException during deserialization

Re setting the value: fresh eyes. In my experience, we all tend to
blitz past the simple bits since they can't *possibly* be wrong ;-p I
am still trying to train myself to start looking at the simple things.

Re the unclear errors; yup, I feel some of that pain.

Marc


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
XML Deserialization Attribute vs. Element .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46