The main problem here is that WCF uses SOAP to send/received data, which is not directly connected to .net but an open web standard. E.g. a java client might also consume the data and hence not know anything about the System.Drawing.Rectangle
namespace. It can however use the Rectangle provided in the Web Service Definition Language and map that to a java Rectangle structure.
In your case, you probably want to cast and convert the System.Drawing.Rectangle
to MyServiceReference.Rectangle
. However, WCF provides built-in support for this by checking the "Reuse types in all referenced assemblies" option in the properties:
When a service reference is added to a project, any types defined in
the service are generated in the local project. In many cases, this
creates duplicate types when a service uses common .NET Framework
types or when types are defined in a shared library.
To avoid this problem, types in referenced assemblies are shared by
default. If you want to disable type sharing for one or more
assemblies, you can do so in the Configure Service References dialog
box.
This link provides an example on how to enable/use this functionality.
Finally, make sure that all the right assemblies are referenced in your client application. If it is not referenced, it obviously cannot be re-used by WCF.