views:

209

answers:

1

Hi all,

Here's a bit subtle issue I'm dealing with, and would appreciate any help.

We have our project on production mode, built with .NET 2.0. We have recently developed a Silverlight application external to the 2.0 solution, and it's "speaking" with a WCF service. This service consumes DLLs we copy from our 2.0 solution publish folders, in order to access functionality from our original solution.

The WCF service is exposing several methods and objects originating from our 2.0 solution. Obviously, it uses [DataContract]s and [DataMember]s internally, and those are not available in our original solution (since it's .NET 2.0, and at this point upgrading to 3.5 is not an option). Fortunately enough, WCF is able to treat our serializable objects as if they were defined as contracts, but for some weird reason only the member variables (even if defined as private!) are being serialized; properties, even settable and public are never serialized.

Our object classes which we need exposed have [Serializable()] defined on them. I have looked around and couldn't find a good solution / explanation to this. It probably has to do with how .NET 3.0/3.5 is "seeing" my 2.0 objects (it assumes [DataMember] only on variables and never on properties).

My question is mainly how to expose public properties only, and never private variables?

Thanks in advance for any insight on this.

Itamar.

A: 

Reason for this remains unknown. We've bypassed this issue by deriving from the exposed object (residing in compiled DLLs we're using through the WCF project) and then re-creating the properties and helper functions we need. We also add new properties or member variables where needed. Then we use that new object internally (this sometimes requires having a specialized constructor to make some copies or adjustments). Not ideal, but working.

synhershko