Trouble getting designer for a component
-
Good morning, I have a custom (windows) user control, which is my own designer host implementation. It all works fine when I run the control in a windows app. I have toolbox, property window, etc. However, I require this form to be implemented in a web page. I am using the <OBJECT> tag to achieve this, and the control is displayed correctly. It all works as per the windows app, with one small problem! In my implementation of IContainer.Add, I call
IDesigner designer = TypeDescriptor.CreateDesigner(component, typeof(IDesigner));
This works fine when hosted in the windows app. In the web however, it returns null. ARGH! If I remove the [Designer] attribute from the control, its ok. I've tried specifying the designer type usingtypeof
and as a fully qualified string. Also tried adding the second parameter (BaseDesignerType) as typeof(IDesigner) and that hasn't helped either?? Apologies for the long post :sigh: its driving me mad!! Anyone have any ideas? Thanks in advance, Simon. -
Good morning, I have a custom (windows) user control, which is my own designer host implementation. It all works fine when I run the control in a windows app. I have toolbox, property window, etc. However, I require this form to be implemented in a web page. I am using the <OBJECT> tag to achieve this, and the control is displayed correctly. It all works as per the windows app, with one small problem! In my implementation of IContainer.Add, I call
IDesigner designer = TypeDescriptor.CreateDesigner(component, typeof(IDesigner));
This works fine when hosted in the windows app. In the web however, it returns null. ARGH! If I remove the [Designer] attribute from the control, its ok. I've tried specifying the designer type usingtypeof
and as a fully qualified string. Also tried adding the second parameter (BaseDesignerType) as typeof(IDesigner) and that hasn't helped either?? Apologies for the long post :sigh: its driving me mad!! Anyone have any ideas? Thanks in advance, Simon.When you host a control in IE, the playing field changes. First of all, is the designer in the same assembly as your control, or a separate assembly? What membership condition identities your assembly and what permission set is granted to it based on matching evidence? Are you simply using FullTrust?
Microsoft MVP, Visual C# My Articles
-
When you host a control in IE, the playing field changes. First of all, is the designer in the same assembly as your control, or a separate assembly? What membership condition identities your assembly and what permission set is granted to it based on matching evidence? Are you simply using FullTrust?
Microsoft MVP, Visual C# My Articles
Hi, Thanks for your information. Yes, the designer is in the same assembly as the control it is designing. This assembly is seperate to the assembly containing the designer host, but as the designer host can 'see' the control, I'm sure it must have access to the designer as well. Both assemblies have full trust (they will only be used on intranet, and security protocols are already in use in other parts of the app, so it's not really a security risk). I have now resolved this problem. I used Reflector to see what
TypeDescriptor.CreateDesigner(IComponent comp, Type designerBaseType)
was doing, and copied the code to a local method so I could debug it. If you are interested, the problem appeared to be thatType.GetType(designerBaseType)
was returning null. (the designerBaseType parameter was hard-coded to IDesigner). I got around this problem by changing all the controls (no, users will never add their own controls to this designer!) to use the constructor of the DesignerAttribute that accepts two parameters, and set the second one to the same type as the first. When the component is then added to the design form, I get the DesignerAttribute for that type, and callTypeDescriptor.CreateDesigner
with the type specified in the second parameter of the attribute. OMG :omg: I don't really understand what I just wrote! :) - it you are really interested, feel free to email me and I'll try to explain in more detail!!! Thanks for your reply. Simon. PS: Is Reflector the most AMAZING tool for .NET development?!?!