Dear:
I'm working web application that expect to pass an class object to DLL(Class
Lib) I just Attached the DLL File into Web Solution ( DLL is located in other
machine), inside the class library I'm calling a webservice function with the
parameter object class , but I just knew that the parameter should be
serializable , so I build class with two functions serialize/derserialize .
in the DLL I did serialize and pass string to the webmethod in webservice
and there a deserialize it and do the rest of work .
the problem I have when serialize the object inside the Component (which is
in other solution) the serialized representation differs and return with
errors than I serialized the object in same web application solution, what
could cause that?
My Serialiazation /Derserialization funcitons:
public string SerializeObject(object oClassObject,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
oSerializer.Serialize(writer,oClassObject);
return strBuilder.ToString();
}
public object DeSerializeObject(string ObjectString,System.Type oClassType)
{
XmlSerializer oSerializer = new XmlSerializer(oClassType);
System.IO.TextReader reader = new System.IO.StringReader ObjectString);
XmlReader xmlReader = new XmlTextReader(reader);
return oSerializer.Deserialize(xmlReader);
}
inside my webapplication
Note : MessageClass in Class Library DLL ( All DLL and WebService are in
standalone machine) and web application in other machine.)
public void PutMessageInQueue(MessageClass oMessage)
{
mail.PutInQueue(oMessage);
}
inside my class library that calls the webservice method
public void PutInQueue(MessageClass Msg)
{
string strSerializedObject = string.Empty;
EW_message.Utility.ObjectHandler oObjectHandler = new
EW_message.Utility.ObjectHandler();
strSerializedObject =
oObjectHandler.SerializeObject(Msg,typeof(EW_Messa ge.MessageClass));
//here i called the webservice method
localEW_MassagingService.PutInQueue(strSerializedO bject);
}
WebService Method
[WebMethod]
public void PutInQueue(string strMsg)
{
EW_message.Utility.ObjectHandler oObjectHandler =
new EW_message.Utility.ObjectHandler();
MessageClass Msg = (MessageClass)
oObjectHandler.DeSerializeObject(strMsg,typeof(EW_ Message.MessageClass));
Random rd=new Random ();
string filename= QueuePath + User + "-" + rd.Next (1,100) +
System.Guid.NewGuid();
StreamWriter QWrite =new StreamWriter(filename);
QWrite.Write (Msg.Message);
QWrite.Close ();
File.Move (filename,filename+".msg");
}
the exception generated inside the DLL before calling the webmethod.
and as I said I copy the serialize/deserialize inside the web application
and everything worked perfectly but when pass it to the dll exception
occured while serializing object.
any Ideas.