WCF: How do I attribute a base .NET class ?

G

Guest

I defined a WCF callback contract:
<ServiceContract()> _
Interface IEBAPEvents
'this interface defines the events to be triggered in the clients
'the EBAP pattern defines two events: a progress event and a completion
event

<OperationContract(IsOneWay:=True)> _
Sub OnProgressChanged(ByVal e As FindFilesProgressChangedEventArgs)

<OperationContract(IsOneWay:=True)> _
Sub OnFindFilesCompleted(ByVal e As FindFilesCompletedEventArgs)
End Interface

and the event args:

<DataContract()> _
Public Class FindFilesProgressChangedEventArgs
Inherits ProgressChangedEventArgs
...

<DataContract()> _
Public Class FindFilesCompletedEventArgs
Inherits AsyncCompletedEventArgs


When starting the WCF host an error message appears:
Error: Type 'System.ComponentModel.ProgressChangedEventArgs' cannot be seria
d. Consider marking it with the DataContractAttribute attribute, and marking
of its members you want serialized with the DataMemberAttribute attribute.

How do I add an attribute to the .NET class ProgressChangedEventArgs ?

thank you very much
herbert
 
S

sloan

Have you tried adding the Serializable attribute?


See example below. You need to "attribute up" both the base class, and
subclass.





using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;



namespace MyCompany.MyApplication
{

[Serializable]
[DataContract]
public class HelpDeskTicketDifficulty
{

[DataMember]
private Guid _helpDeskTicketDifficultyUUID;

[DataMember]
private int _helpDeskTicketDifficultyID;

[DataMember]
private string _helpDeskTicketDifficultyName = string.Empty ;


public HelpDeskTicketDifficulty() { } //unnecessary, but a
placeholder

public HelpDeskTicketDifficulty(System.Guid
helpDeskTicketDifficultyUUID, int helpDeskTicketDifficultyID, string
helpDeskTicketDifficultyName)
{
this._helpDeskTicketDifficultyUUID =
helpDeskTicketDifficultyUUID;
this._helpDeskTicketDifficultyID = helpDeskTicketDifficultyID;
this._helpDeskTicketDifficultyName =
helpDeskTicketDifficultyName;
}


#region A

public Guid HelpDeskTicketDifficultyUUID
{
get
{
return this._helpDeskTicketDifficultyUUID;
}
set
{
this._helpDeskTicketDifficultyUUID = value;
}
}


public int HelpDeskTicketDifficultyID
{
get
{
return _helpDeskTicketDifficultyID;
}
set
{
_helpDeskTicketDifficultyID = value;
}
}

public string HelpDeskTicketDifficultyName
{
get
{
return _helpDeskTicketDifficultyName;
}
set
{
_helpDeskTicketDifficultyName = value;
}
}


#endregion

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top