I am trying to implement a method that get's called on deserializing
a custom component
.
However, the methods marked as OnDeserializing
and OnDeserialized
are never called.
I found this question on SO and from the text I conclude that here these method's are being called. So I compared this code with mine.
Also in the documentation I cannot see anything that I am missing.
What I need is that when my custom component
is deserializing
from the Designer.cs
on designtime, I can step in and do some extra coding.
So what am I missing here ?
[Serializable]
public partial class gttDataTable : Component, ISerializable
{
private Collection<ConfigColumn> _columns = new Collection<ConfigColumn>();
public gttDataTable()
{ }
public gttDataTable(SerializationInfo info, StreamingContext context)
{ }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Collection<ConfigColumn> gttColumns
{
get { return _columns; }
set { _columns = value; }
}
[OnDeserializing]
internal void OnDeserializingMethod(StreamingContext context)
{
// this code is never called
throw new NotImplementedException();
}
[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
// this code is never called
throw new NotImplementedException();
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
// this code is never called
throw new NotImplementedException();
}
private IComponentChangeService GetChangeService()
{
return (IComponentChangeService)GetService(typeof(IComponentChangeService));
}
}
public class ConfigColumn
{
public string Name { get; set; }
public string Caption { get; set; }
public string ColumnName { get; set; }
public Type DataType { get; set; }
}
EDIT
For clarity, the problem is that both the internal methods are never called when the custom component is deseriazeling.
EDIT 2
I tried making the internal methods public, as suggested, but it makes no difference. They still are not called
EDIT 3
I read this link and doublechecked that all is the same as in the documetation. In my opinion it is all correct, but still the methods are not called