Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / November 2005

Tip: Looking for answers? Try searching our database.

Root designer and form serialization problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sergey M - 17 Oct 2005 20:54 GMT
Hi all,

We have a custom form designer that is based on Microsoft's sample
available for download. There were few things missing in that sample
that we've added:
- IExtenderListService implementation for site class
- GetExtenderProviders() for site class that calls into class host
- our own design form, which is declared as: DesignForm : Form, with
the following attribute:
Designer("DesignerHost.Designers.DesignFormDesigner,
DesignerHost.Designers", typeof(IRootDesigner))
- our own form designer declared as DesignFormDesigner :
DocumentDesigner

Everything seems to work fine except serialization. It appears that
most of the newly created design form properties simply don't
serialize. After some extensive research we found the cause of the
problem, which appears to lie in Microsoft's design support classes.
Here's what happens:
- When our form designer is created, it calls into base.Initialize(),
which is followed by PreFilterProperties()/PostFilterProperties()
calls while it's still in base.Initialize()
- Right after those 2 calls DocumentDesigner().Initialize() adds 3
designer extenders (LocalizationExtenderProvider, etc.) to the site
- Next call to TypeDescriptor.GetProperties() for our designer
component fails to find previouselly cached component type reference
in its cache because number of extender providers is taken into
account when performing cache lookups (that's due to the previous item
I've just mentioned)!
- The above TypeDescriptor.GetProperties() resolution failure causes
our ITypeDescriptorFilterService.FilterProperties() implementation to
be called, which in turn calls into our designer
PreFilterProperties()/PostFilterProperties() for the 2nd time!
- That eventually calls into ComponentDesigner.PostFilterProperties(),
which swaps most of the cached properties types from
ReflectPropertyDescriptor to InheritedPropertyDescriptor
- During serialization,
InheritedPropertyDescriptor.ShouldSerializeValue() acts slightly
differently from ReflectPropertyDescriptor.ShouldSerializeValue(), but
enough to reject the value changes as not required serialization,
hence the problem

This is rather an advanced subject and I wouldn't be surprised if I
don't get many replies. I hope this makes sense and that good people
at Microsoft will be able to shed some light on it. I'd appreciate any
suggestions at this point. Thanks.

PS We use VS.NET 2003.
Signature

Sergey Mishkovskiy
http://www.usysware.com/dpack/ - DPack - free VS.NET add-ons
http://www.usysware.com/blog/

Sergey M - 02 Nov 2005 22:30 GMT
> This is rather an advanced subject and I wouldn't be surprised if I
> don't get many replies. I hope this makes sense and that good people
> at Microsoft will be able to shed some light on it. I'd appreciate
> any suggestions at this point. Thanks.

Anyone?
Signature

Sergey Mishkovskiy
http://www.usysware.com/dpack/ - DPack - free VS.NET add-ons
http://www.usysware.com/blog/

mesterak - 28 Nov 2005 19:15 GMT
You may want to have a look at MyXAML source code for help and ideas
(www.myxaml.com.)  The project author gave me some tips/pointers to help me
with my designer host project.  Unfortunately, I haven't found much about
designer host technologies, etc. on the internet either.  I even posted a my
designer host issues on experts exchange but received no replies after 30
days, so I pulled the question.

Don't know if this will be useful, but here is a little bit about what I did
with the MS sample designer host app:

I have used Microsoft's example for a "custom dialog generator" project and
had issues with serialization, but my issues are unrelated to the issues you
identify here.  I attempted to add custom controls where I could hide many
control properties from the PropertyGrid control.  In doing so, I had issues
with serialization, especially where my custom controls included new
(extended properties), etc.  The key to making things work correctly in the
end was properly adding attributes for serialization, etc. to my extended
properties in a wrapper class.  I ended-up turning the sample designer host
solution into a DLL (not too hard to do.)  I utilize the sample's generate
code methods to get the layout details in XML format.  I then parse the form
and control properties into a custom, serializable class which contains
extended properties the user can set; e.g. button click behaviors, etc.  I
serlialize my custom class into XML.  This XML can then be used directly via
my rendering engine to create custom dialogs or forms.

> Hi all,
>
[quoted text clipped - 44 lines]
>
> PS We use VS.NET 2003.
mesterak - 28 Nov 2005 19:22 GMT
Try looking at the MyXAML code for ideas (www.myxaml.com.)  Maybe the project
author can give you some tips/pointers.

I, too, had issues with serialization although it was not similar to your
issues, which are not very clear to me.  I ended-up wrapping the sample
designer host app as a DLL and use it a designer for a custom dialog/form
creation engine.  I utilize the app's built-in (codedom) serialization to XML
to get the forms/controls layout.  The only updates I have made to the
designer host was adding my own custom controls with extended properties and
added the code for enabling the cut, copy, paste features selected via menu.

Hope this helps...

-Matt

> Hi all,
>
[quoted text clipped - 44 lines]
>
> PS We use VS.NET 2003.
Sergey M - 29 Nov 2005 15:14 GMT
> Try looking at the MyXAML code for ideas (www.myxaml.com.)  Maybe
> the project
> author can give you some tips/pointers.

Thanks Matt, I'll take a look at MyXAML. I appreciate you taking time
to reply.
Signature

Sergey Mishkovskiy
http://www.usysware.com/dpack/ - DPack - free VS.NET add-ons
http://www.usysware.com/blog/

mesterak - 29 Nov 2005 19:57 GMT
Let me know how things work out for you :)

> > Try looking at the MyXAML code for ideas (www.myxaml.com.)  Maybe
> > the project
> > author can give you some tips/pointers.
>
> Thanks Matt, I'll take a look at MyXAML. I appreciate you taking time
> to reply.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.