tags:

views:

1447

answers:

2

I am fairly new to WCF and have created a few services, so I have some experience with WCF. I want to create multiple services that can use a single FaultContract. I have noticed that the Fault type needs to be in the same project to make use of the [DataContract] and member attributes. Is this true or is there something I can do to add the contracts? Here is what I would like to do:

NameSpace Service1{

 [ServiceContract()]
 iService1Interface1{
      [OperationContract()]
      [FaultContract(typeOf(ServiceFault.Fault)]
      DoTheWork1();
 }

}

NameSpace Service2{

 [ServiceContract()]
 iService1Interface2{
      [OperationContract()]
      [FaultContract(typeOf(ServiceFaults.Fault)]
      DoTheWork2();
 }

}

NameSpace ServiceFaults{ [DataContract] public class Fault{ public Fault(message){ //build a message
}

        [DataMember]
        public Message{}
   }

}

Does this make sense? Thanks

Daniel

A: 

I don't believe it needs to be in the same project. Projects are Visual Studio things, not .NET things.

What happens when you use separate projects? Do you specify the type including the namespace? Do you reference the assembly containing the fault contracts?

John Saunders
I can't decorate the Class or proties, for the fault class, with DataContract / DataMember. Or do I even need them? i might be misunderstanding their purpose.
DDiVita
A: 

I thought I had the System.Runtime.Serialization referenced in my project, but it wasn't there. So silly!

DDiVita