Take the 2-minute tour ×
class MyCommonClass

This class should be accessible in

  1. service project
  2. wcf-client project
  3. the other for which they are references. In this common project I can't generate servicereferences.

I think, I could don't generate MyCommonClass in ServiceReferences but how to mark class to be nonserializable? In properties there's IgnoreDataMemberAttribute. I tried also reuse MyCommonClass type located in common project, but it is still generated


In different words: if some type is used in ServiceOperation it's automatically generated into wsdl document. How to disable it? (I don't want it on wcf-client side)

share|improve this question
add comment

1 Answer

It's not clear whether the common class needs to part of a WCF service contract so it can be made available to any client through the WSDL document or if you are trying make the common class accessible to both the WCF service and the WCF client as a standard .NET class.

The only reason to share a standard .NET class between the service and the client is to provide access to shared logic. Otherwise, just mark that class with either DataContract or Serializable to let the service expose the class to the client thru WSDL. Just remember that one of the four tenets of SOA is to share types (WSDL) not classes (.NET assemblies).

Based on the updated question, you can achieve better control over what WCF serializes into soap XML by forcing WCF to use the XmlSerializer instead of the default DataContractSerializer. Also, you may want to decouple the domain model objects from what objects are exposed by the WCF service as discussed in this SO question and answers. This excellent blog post explains the differences between the two serializers and how to force WCF to use the XmlSerializer.

share|improve this answer
MyCommonClass is used in some abstract classes etc, that are not supported by wsdl document (abstract classes are generated in wsdl like standard classes). Furthermore these abstract classes and their derivatives are not used in ServiceOperation method, so they can't be generated in wsdl document though marked as OperationContract –  Saint Oct 23 '12 at 20:10
WCF is an abstraction over a message-based client/service architecture. It was not design as a distributed object oriented framework which is why abstract types are not really supported. The approach you're attempting is poorly supported in WCF. Think of WCF as an object oriented abstraction over an XML-based messaging (soap) exchange pattern. You're trying to push an object oriented abstraction through an XML message exchange pattern. –  Sixto Saez Oct 24 '12 at 2:49
You don't understood. I know it. I won't push abstract structure over wcf. I need to share some class in common project and I'd like don't serialize this type to wsdl document. I'm looking for such attributes or another way –  Saint Oct 24 '12 at 7:28
add comment

Your Answer


