Hey Folks,

Just ran into this minor quirk today, figured I'd share the solution. I have a Webservice that returns an array of a class defined on the server. On the client side, I wanted to extend that class to link it to some GUI elements. Enter the partial class. If you haven't played with Partial Classes before, I'd recommend checking them out. It allows you to build additional functionality into any class. Not by inheriting from a base, but actually extending that class without creating a new one. Anyways, I wound up with the following:

Namespace srAlerts
    Partial Public Class Alert

        Private _CommentDisplay As CommentIndicator
        <System.Xml.Serialization.XmlIgnore()> _
        Public Property CommentDisplay() As CommentIndicator
            Get
                Return _CommentDisplay
            End Get
            Set(ByVal value As CommentIndicator)
                _CommentDisplay = value
            End Set
        End Property

    End Class
End Namespace

srAlerts is the namespace of my web service. Alert is the name of the class defined in my web service. CommentIndicatory is the GUI control that I was linking to.

The critical part though, is the attribute. Without the System.Xml.Serialization.XmlIgnore attribute, you'll get an exception on the constructor of the web service Reference.vb file:

Exception has been thrown by the target of an invocation.

-There was an error reflecting type ‘Alerts.srAlerts.BaseResponse’.

–There was an error reflecting type ‘Alerts.srAlerts.GetAlertDataResponse’.

—There was an error reflecting property ‘Alerts’.

—-There was an error reflecting type ‘Alerts.srAlerts.Alert’.

—–There was an error reflecting property ‘CommentDisplay’.

It would appear that the web service system in Silverlight attempts to serialize all members of the class, even those that are defined client side in a partial class, and it gets a little confused. Using the XMLIgnore attribute forces the serializer to skip this property and allows us to use the partial class on the client side as we expected.

On a side note, there is also a WCF attribute: System.Runtime.Serialization.IgnoreDataMember which will NOT work for web service references.

-Rick