TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Romain
NA
76
39.3k
Refer to an attribute within the serialization
Dec 11 2020 9:54 AM
Good morning,
I am working on a software which mix C# and C++/CLI between different application domains. I have implemented a solution with cross app domain singleton and ISerialisable interface in order to send information between two different application domains. It works fine but now I encounter a problem with the object that is serialized. The objet is used for displaying a message ( the message comes from C++/CLI layer and "travel" between the application domains with cross app domain singleton ) in a text box of a windows form. I got the message but I can't display it in the textbox because I don't have any reference on it (due to the process of serialization). Is there any way to do this ?
See below the code I am using :
[Serializable]
class
MsgObserver : ISerializable
{
public
System.Windows.Forms.RichTextBox m_rTxtBox;
public
MsgObserver(System.Windows.Forms.RichTextBox txtBox)
{
m_rTxtBox = txtBox;
}
public
void
notifyInfoMessage(
string
infoMessage)
{
m_rTxtBox.Text +=
"INFO :"
+ infoMessage;
}
protected
MsgObserver(SerializationInfo info, StreamingContext context)
{
m_rTxtBox = (System.Windows.Forms.RichTextBox)info.GetValue(
"resultBox"
,
typeof
(System.Windows.Forms.RichTextBox));
}
void
ISerializable.GetObjectData(SerializationInfo oInfo, StreamingContext oContext)
{
oInfo.AddValue(
"resultBox"
, m_rTxtBox);
}
}
Before the process of calling C#/CLI, I initialize the object like that :
MsgObserver observer = new MsgObserver(txtBox);
What I saw is during the process of serialization, I enter to "protected MsgObserver" constructor and I lost the reference to the text box.
Thank you in advance for any help.
Romain.
Reply
Answers (
0
)
How to Import/Download csv file in Jquery datatable
ListView1 View.List