I have some custom controls with a property
public MyComponent MyObject { get; set; }
MyComponent is derived from Component. If I set the class of MyObject to Component I can select any control from the form within the designer (VS 2008). But if I use MyComponent as class (to ensure that onlyinstances ofthis class can be used)I get an exception while loading the form in designer (for all custom properties in my controls). Seems there is a problem loading MyComponent (missing some methods). I havesearched the forums and the internet but didn't find a howto which methods and interfaces from component I have to override.
It's sure simple... | | AlterEgo Monday, April 20, 2009 12:01 PM | Hi Bruce, thanks for your great help. I think I've found the solution more randomly. Here's the location http://social.msdn.microsoft.com/forums/en-US/windowsmobiledev/thread/d9d80b8f-8ff3-4799-898e-766fef295315/Sorry, I didn't explain that I use compact framework to ensure that the controls can be used on both platforms. The problem seems to be specific to CF. And thus I need an xmta file to publish properties for the designer (I cannot use [...] in my code). Best Regards, Harald Pitro - Marked As Answer byBruce.ZhouMSFT, ModeratorFriday, April 24, 2009 6:52 AM
-
| | AlterEgo Friday, April 24, 2009 6:14 AM | Hi AlterEgo, I not sure when you said "if I use MyComponent as Class", would you please clarify? Besides, what's the detail of the exception? Best regards, Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't. | | Bruce.Zhou Thursday, April 23, 2009 7:12 AM | Hi Bruce, thanks! Here's some code:
public c
lass MyComponent : Component { public MyComponent() : base() { InitializeComponent(); }
public MyComponent(IContainer container) : base() { container.Add(this); InitializeComponent(); } }
// next code ist OK, if I drag the MyComponent and MyTextBox on a form, // I can select the property MyObject (if I publish it in an xmta file) // but I can now select any component on the form in this property public class MyTextBox : TextBox { public Component MyObject { get; set; } }
// but if I write that code I get exceptions (in detail VS loops through Serializer methods) // the exception tells me that it cannot find the type MyComponent public class MyTextBox : TextBox { public MyComponent MyObject { get; set; } }
Regards, Harald Pitro
P.S. MyComponent and MyTextBox are stored in separate asemblies. | | AlterEgo Thursday, April 23, 2009 9:21 AM | Hi AlterEgo, I think the problem is caused by not adding MyComponent assembly as reference, so the designer can't recognize MyComponent type. To solve this problem, you need to add reference in MyTextBox project by right clicking "Reference" node in the Solution Explorer, and then click add reference. At last, locate the assembly file for MyComponent type, and click Ok. If the problem can't be solved or any further problem, please feel free to let me know. Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't. | | Bruce.Zhou Friday, April 24, 2009 3:32 AM | Hi Bruce,
I can compile the MyTextBox assembly and there is a reference to the MyComponent asembly.There is no error in compiling both assemblies.
I get the exception if I open the form where MyComponent and MyTextBox are placed on. This form has references to both, MyComponent and MyTextBox.
Best Regards, Harald Pitro | | AlterEgo Friday, April 24, 2009 5:18 AM | Hi AlterEgo, I tried to reproduce the problem with code and steps you provided, but the problem can't be reproduced on my side. Which version of Visual Studio did you use? The project I created to reproduce the problem is using Visual Studio 2008 SP1. >// next code ist OK, if I drag the MyComponent and MyTextBox on a form, >// I can select the property MyObject (if I publish it in an xmta file) >// but I can now select any component on the form in this property What did you mean by saying "if I publish it in an xmta file"? Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't. | | Bruce.Zhou Friday, April 24, 2009 5:58 AM | Hi Bruce, thanks for your great help. I think I've found the solution more randomly. Here's the location http://social.msdn.microsoft.com/forums/en-US/windowsmobiledev/thread/d9d80b8f-8ff3-4799-898e-766fef295315/Sorry, I didn't explain that I use compact framework to ensure that the controls can be used on both platforms. The problem seems to be specific to CF. And thus I need an xmta file to publish properties for the designer (I cannot use [...] in my code). Best Regards, Harald Pitro - Marked As Answer byBruce.ZhouMSFT, ModeratorFriday, April 24, 2009 6:52 AM
-
| | AlterEgo Friday, April 24, 2009 6:14 AM | Hi AlterEgo, Thanks for your reply. Glad you found the solution addressing your problem. Best regards, Bruce Zhou Please mark the replies as answers if they help and unmark if they don't. | | Bruce.Zhou Friday, April 24, 2009 6:52 AM |
|