I came across this many years ago when developing a layered application. I hope your situation is the same as mine, so it will be useful.
Our setup was that we had one server, intended only for servicing web services for transferring data between all other components.
Classes were defined in the web service project. Example:
<Serializable()> _ Public Class RetailInformation_StoreInformation ... End Class
When we had a client class, try to deserialize the serialized data, we could not do that. We tried to copy the DLL containing the RetailInformation_StoreInformation class to client applications, but that would just not deserialize.
In the end, we discovered this.
Say we have a client application called StoreInfoDisplayApp
In the StoreInfoDisplayApp project, we added a web link to a web service called RetailInfoService.
We found that we cannot deserialize the RetailInformation_StoreInformation from the dll as follows:
Private Function DeSerializeStoreInfo(ByVal path As String) As RetailInformation_StoreInformation Dim ser As New System.Xml.Serialization.XmlSerializer(GetType(RetailInformation_StoreInformation)) Dim reader As System.IO.Stream = File.OpenRead(path) Dim returnvalue As RetailInformation_StoreInformation = CType(ser.Deserialize(reader), RetailInformation_StoreInformation) reader.Close() Return returnvalue End Function
because the compiler (or the runtime is foggy) viewed this as StoreInfoDisplayApp.RetailInformation_StoreInformation
Instead, we had to change all instances
RetailInformation_StoreInformation
to
RetailInfoService.RetailInformation_StoreInformation
to indicate that the type we are deserializing was the same type that the web service served. Then it worked like a peach!