Groups | Blog | Home
all groups > dotnet windows forms designtime > june 2007 >

dotnet windows forms designtime : How do you persist and restore forms with the CodeDomDesignerLoade


Bill Rust
6/12/2007 6:51:01 AM
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,
v-lliu NO[at]SPAM online.microsoft.com
6/13/2007 12:08:26 PM
Hi Bill,

This is a quick note to let you know that I am performing research on this
issue and will get back to you ASAP.

I appreciate your patience!


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
v-lliu NO[at]SPAM online.microsoft.com
6/15/2007 12:00:00 AM
Hi Bill,

There's no direct way to parse source code to CodeCompileUnit object. You
may need to analysis every line of statement in the source code and
construct a CodeDOM object model.

It seems that it is not an easy job. I search the Internet and find a
parser called CS CODEDOM Parser, which is a utility to parse the C# source
code and creates the CODEDOM tree of the code.

You may refer to the following article for more information on this.

'CS CODEDOM Parser'
http://www.c-sharpcorner.com/UploadFile/ivan.zderadicka/CsCodeParser12052005
234428PM/CsCodeParser.aspx

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support
v-lliu NO[at]SPAM online.microsoft.com
6/20/2007 12:00:00 AM
Hi Bill,

How about the problem now?

If you need our further assistance, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
AddThis Social Bookmark Button