Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

CommunicationException during deserialization

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 04-26-2007   #1 (permalink)
StanB
Guest


 

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
Guest


 

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
Guest


 

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
Guest


 

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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Deserialization Attribute vs. Element Todd .NET General 2 02-28-2008 01:40 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51