Bill Rust
2007-06-12 13:51:01 UTC
I'm implemented a forms editing environment based on the MSDN example:
http://msdn.microsoft.com/msdnmag/issues/06/03/designerhosting/default.aspx.
My DesignerLoader derives from CodeDomDesignerLoader, and I'd like to persist
the form definition to a file so that it can be subsequenly reopened and
edited. I can persist the CodeCompileUnit to a file using the
BinaryFormatter, and I can recreate the CodeCompileUnit from the file using
the following code:
SAVING
FileStream fs = new FileStream("e:\\temp\\ccu.dat", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, codeCompileUnit);
fs.Close();
LOADING
FileStream fs = new FileStream("e:\\temp\\ccu.dat", FileMode.Open);
BinaryFormatter formatter = new BinaryFormatter();
ccu = (CodeCompileUnit)formatter.Deserialize(fs);
fs.Close();
I return the inflated CodeCompileUnit from my implementation of
CodeDomDesignerLoader.Parse, but the form is only properly reconstructed in
the form designer if it contains no child controls. As soon as I add a child
control (doesn't matter which one), I'm unable to restore the form using the
persisted CodeCompileUnit. Note that I have this problem even if the child
controls do not reference resource data. What do I need to do to
successfully restore the form from persistent storage?
Thanks,
Bill
http://msdn.microsoft.com/msdnmag/issues/06/03/designerhosting/default.aspx.
My DesignerLoader derives from CodeDomDesignerLoader, and I'd like to persist
the form definition to a file so that it can be subsequenly reopened and
edited. I can persist the CodeCompileUnit to a file using the
BinaryFormatter, and I can recreate the CodeCompileUnit from the file using
the following code:
SAVING
FileStream fs = new FileStream("e:\\temp\\ccu.dat", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, codeCompileUnit);
fs.Close();
LOADING
FileStream fs = new FileStream("e:\\temp\\ccu.dat", FileMode.Open);
BinaryFormatter formatter = new BinaryFormatter();
ccu = (CodeCompileUnit)formatter.Deserialize(fs);
fs.Close();
I return the inflated CodeCompileUnit from my implementation of
CodeDomDesignerLoader.Parse, but the form is only properly reconstructed in
the form designer if it contains no child controls. As soon as I add a child
control (doesn't matter which one), I'm unable to restore the form using the
persisted CodeCompileUnit. Note that I have this problem even if the child
controls do not reference resource data. What do I need to do to
successfully restore the form from persistent storage?
Thanks,
Bill