Serialize/Deserialize data class from different assemblies
-
Hi gurus, I'm new to .NET Remoting and I have this problem. I have an assembly, API.dll, that contains all the abstract functions and data classes. I have a separate assemby, APIImpl.dll, that overrides the functions and data classes. Let's focus on my this one: One of my abstract data class in API.dll is read-only, meaning it only have the getter. The setter of this data class is in APIImpl.dll. I wanted to implement remoting to cater for some requirements. I made all my data classes Serializable. However, when i tried testing the remoting that i implemented, I encountered a SerializationException and the message is 'Unable to locate APIImpl.dll'. From what I understand about remoting is that the implementation dll does not necessarily to be in the client machine. But base on the exception that I encountered, in the client application it's still searching the implementation assembly. Please help. :( Thanks in advance.
-
Hi gurus, I'm new to .NET Remoting and I have this problem. I have an assembly, API.dll, that contains all the abstract functions and data classes. I have a separate assemby, APIImpl.dll, that overrides the functions and data classes. Let's focus on my this one: One of my abstract data class in API.dll is read-only, meaning it only have the getter. The setter of this data class is in APIImpl.dll. I wanted to implement remoting to cater for some requirements. I made all my data classes Serializable. However, when i tried testing the remoting that i implemented, I encountered a SerializationException and the message is 'Unable to locate APIImpl.dll'. From what I understand about remoting is that the implementation dll does not necessarily to be in the client machine. But base on the exception that I encountered, in the client application it's still searching the implementation assembly. Please help. :( Thanks in advance.
A serialized class stores full names or your class and the properties of this class. If your server serializes a class of your Apiimpl.dll than this assembly name is stored within the full name of the class. So for deserialization this assembly must be present on your client. A common way is to use interfaces:
// API.dll:
public interface IDataClass {
int DataField { get; set; }
}// APIIMPL.dll:
public class DataClass: IDataClass {
private int dataField;public int DataField { get { return dataField; } set { dataField=value;} }
}So on your client is no code from your server. This works the best. Try out the xml serialization to see and understand whats happened to your classes during serialization (search for XmlObjectSerializer in your msdn library). occcy
-
A serialized class stores full names or your class and the properties of this class. If your server serializes a class of your Apiimpl.dll than this assembly name is stored within the full name of the class. So for deserialization this assembly must be present on your client. A common way is to use interfaces:
// API.dll:
public interface IDataClass {
int DataField { get; set; }
}// APIIMPL.dll:
public class DataClass: IDataClass {
private int dataField;public int DataField { get { return dataField; } set { dataField=value;} }
}So on your client is no code from your server. This works the best. Try out the xml serialization to see and understand whats happened to your classes during serialization (search for XmlObjectSerializer in your msdn library). occcy
hi occcy, thanks for your explanation. that's the way i understand it also. but the current project that i'm working on, in the interface/abstract class they only have the get. then the set is in the implementation dll.
// API.dll:
public interface IDataClass {
int DataField { get; }
}// APIIMPL.dll:
public class DataClass: IDataClass {
private int dataField;
public int DataField { get { return dataField; } set { dataField=value;} }}is there any tweak that i can implement for this to work in remoting??
-
Hi gurus, I'm new to .NET Remoting and I have this problem. I have an assembly, API.dll, that contains all the abstract functions and data classes. I have a separate assemby, APIImpl.dll, that overrides the functions and data classes. Let's focus on my this one: One of my abstract data class in API.dll is read-only, meaning it only have the getter. The setter of this data class is in APIImpl.dll. I wanted to implement remoting to cater for some requirements. I made all my data classes Serializable. However, when i tried testing the remoting that i implemented, I encountered a SerializationException and the message is 'Unable to locate APIImpl.dll'. From what I understand about remoting is that the implementation dll does not necessarily to be in the client machine. But base on the exception that I encountered, in the client application it's still searching the implementation assembly. Please help. :( Thanks in advance.
This article might help: # Advanced Binary Serialization: Deserializing an Object Into a Different Type Than the One It was Serialized Into[^]
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion