locked
Adding an ITypeDescriptorFilterService to VS designer RRS feed

  • Question

  • I have a dilemma.
    I want to provide a custom CodeDomSerializer for specific Windows Forms controls that are provided by a 3rd party. This means that I cannot put a DesignerSerializer attribute on the class.
    I found a way to do this.
    I have written a Component that has a Designer (ComponentDesigner), in the Designer.Initialize method, I register an ITypeDescriptorFilterService.
    This service filter attributes for ALL components on a form, and adds the DesignerSerializerAttribute to the components of my choice.
    That serializer is then used by the designer to create all the InitializeComponent code that I want.
    This works perfectly.

    The problem arises when opening the form for the first time. It seems that FilterAttributes is never called for the components whose CodeDom I overrode - so I can never put the DesignerSerializerAttribute on the type, and hence the deserialization fails because VS does not know how to interpret my custom CodeDom.

    This kind of makes sense, becuase in the TypeDescriptorFilterService, FilterAttributes takes an IComponent as its first parameter - how can Visual Studio instantiate the component to filter its attributes if it hasnt had the DesignerSerializer defined for it yet?

    So, what I need to know, is how to I get down to a deeper level, so that I can ensure my DesignerSerializerAttribute is placed on the component BEFORE the Design Surface attempts to deserialize the InitializeComponent code?

    Any tips on what services I need to be using?

    Thanks in advance - this one is doing my head in!!

    • Moved by Feng Chen Saturday, June 14, 2008 7:01 AM A winform designer issue.
    Wednesday, June 11, 2008 12:20 AM

Answers

  • Recommended posting this question in Windows Forms Designer forum to getter better answer, in which ciscuss features of the Windows Forms designer inside of Visual Studio as well as custom control designers and hosting the Windows Forms designer in your app.

    Thanks!

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Saturday, June 14, 2008 7:00 AM
  • This was moved to the Off Topic forum. I can move it to a specific forum for you, if you'd like.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Thursday, May 10, 2012 6:58 AM

All replies

  • Recommended posting this question in Windows Forms Designer forum to getter better answer, in which ciscuss features of the Windows Forms designer inside of Visual Studio as well as custom control designers and hosting the Windows Forms designer in your app.

    Thanks!

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Saturday, June 14, 2008 7:00 AM
  • This was moved to the Off Topic forum. I can move it to a specific forum for you, if you'd like.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Thursday, May 10, 2012 6:58 AM