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 / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Extender Provider code generation bug

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Müller - 13 Dec 2004 20:07 GMT
Hi!

I think I've found a bug in the way code gets generated for an extender
provider property.
My extender provider is to provide a control to another control, that, when
clicked, will pop up a FolderBrowser and set the first control's text to the
selected folder.
Basically this means bringing textboxes and buttons together by defining
which button to click to select a path displayed in a text box.
That's my ProvidePropertyAttribute:
[ProvideProperty("BrowseButton", typeof(Control))]

Everything works OK as long as extendee and BrowseButton (the property
provided) aren't the same object.

When I try to set a control to be its own BrowseButton (in this example, a
linkLabel), I get this bad code generated:

this.folderBrowserExtenderProvider1.SetBrowseButton(this.linkLabel1,
this.folderBrowserExtenderProvider1.SetBrowseButton);

instead of

this.folderBrowserExtenderProvider1.SetBrowseButton(this.linkLabel1,
this.linkLabel1);

When I add the correct call to SetBrowseButton() to code manually,
everything works as expected, but selecting the control in the designer
always produces the bogus code above.

Can anybody help? What can I do?

Thanks in advance,
Martin Müller
"Jeffrey Tan[MSFT]" - 14 Dec 2004 02:19 GMT
Hi Martin,

Thanks for your posting!

Based on my understanding, you implemented a IExtenderProvider, which add a
"BrowseButton" property to other controls on the form. But when you set the
extended property for a control of the same type as the provided property,
you find that the VS.net designer will generate incorrect code for it.

I am not sure of how you implement the "BrowseButton" class and
SetBrowseButton/GetBrowseButton methods, can you paste some code snippet or
a sample project for me to reproduce out this issue? Then, I can help you
better. Thanks. I will wait for your further feedback.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Martin Müller - 14 Dec 2004 07:09 GMT
Dear Jeffrey,
thanks for your interest.

Here's the code for one of the extenders that shows the problem:

[ProvideProperty("BrowseButton", typeof(Control))]
public class FolderBrowserExtenderProvider : Component, IExtenderProvider
{
 private Hashtable extendees;
 protected FolderBrowserDialog folderDialog;

 public FolderBrowserExtenderProvider()
 {
   extendees = new Hashtable();
   folderDialog = new FolderBrowserDialog();
 }

 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 public System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog
 {
   get {  return folderDialog; }
 }
       
 public bool CanExtend(object extendee)
 {
   return (extendee is Control);
 }

 [DefaultValue(null)]
 public Control GetBrowseButton(Control extendee)
 {
   if (extendees.Contains(extendee))
       return (Control)extendees[extendee];
   else
     return null;
 }

 public void SetBrowseButton(Control extendee, Control browseButton)
 {
   if (extendees.Contains(extendee))
   {
     Control btn = extendees[extendee] as Control;
     btn.Click -= new EventHandler(browseButton_Click);
     extendees.Remove(extendee);
   }
   if (browseButton == null)
     return;

   extendees[extendee] = browseButton;
   browseButton.Click += new EventHandler(browseButton_Click);
 }

 // browseButton_Click omitted for shortness
}
-------------------------
Hope you can reproduce the behaviour.
It only occurrs when you try to assign a control to be its own BrowseButton
via the VS designer.

Regards,
Martin Müller

> Hi Martin,
>
[quoted text clipped - 15 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 15 Dec 2004 08:33 GMT
Hi Martin,

Thanks very much for your feedback!!

Yes, with your code snippet, I have reproduced out your issue. I will spend
some more time on this issue to do some research. I will reply to you ASAP.
Thanks for your understanding!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

"Jeffrey Tan[MSFT]" - 17 Dec 2004 05:53 GMT
Hi Martin,

Sorry for letting you wait for so long.

I have created a sample reproduce project and help you to feedback it to
our product team, and our product team may review this issue.

Also, you may provide your own suggestion for this issue to
"http://register.microsoft.com/mswish/suggestion.asp".

If you still have much concern on this issue, and is urgent on it, please
feel free to tell me, I will provide you the way to contact our PSS. The
PSS may help you to obtain a hotfix for it.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Martin Müller - 19 Dec 2004 15:31 GMT
Dear Jeffrey,

thanks for propagating the case to the product team.

Do you know of any workarounds?
Right now I'm throwing an exception when i'm at design time and trying to
assign a control to be it's own extender, but that's not really elegant.

Any ideas?

Thanks,
Martin Müller

> Hi Martin,
>
[quoted text clipped - 19 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 20 Dec 2004 06:41 GMT
Hi Martin,

Thanks for your feedback!

Yes, I have already tried to find a workaround for you, but since there is
little thing we can do to the Code generation in VS.net design-time, I
still can not find a workaround for this issue. So I say that if this issue
has much impact on your business, you may contact PSS to request a hotfix.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Martin Müller - 20 Dec 2004 08:37 GMT
OK, I'll consider this possibility.

Thanks,
Martin Müller

> Hi Martin,
>
[quoted text clipped - 11 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 21 Dec 2004 05:48 GMT
Ok, if you need further help, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


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.