Microsoft KB Archive/325159

= PRB: Incorrect Code is Generated for the HelpProvider Component =

Article ID: 325159

Article Last Modified on 7/26/2002

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition

-



This article was previously published under Q325159



SYMPTOMS
If you set the Localizable property of a C# Windows form to True, incorrect code is generated for the HelpProvider component.

With the C# compiler, you receive the following errors:

error CS1502: The best overloaded method match for 'System.Windows.Forms.HelpProvider.SetHelpKeyword(System.Windows.Forms.Control, string)' has some invalid arguments

error CS1503: Argument '2': cannot convert from 'object' to 'string'



CAUSE
The code that is generated by the Windows Forms Designer is incorrect.

Both the HelpProvider.SetHelpKeyword and the HelpProvider.SetHelpString methods expect a string as their second argument, however, the code that is generated passes an object as the second argument instead.



RESOLUTION
To resolve this issue, use either of the following methods:
 * Cast the second argument into a String.
 * Use the ToString method of the object.

NOTE: After you use either of these methods, you have to specify a valid second argument to the method call. For example, the SetHelpKeyword method of the HelpProvider class expects a Help keyword to be associated with a control.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior

 * 1) Create a new Visual C# Windows application. Form1 is added by default.
 * 2) Set the Localizable property of Form1 to True.
 * 3) Add a Windows Forms HelpProvider component to Form1. When it is added to a form, the HelpProvider component appears in the notification area at the bottom of the Windows Forms Designer.
 * 4) Build the project. You receive the errors that are mentioned in the &quot;Symptoms&quot; section.

Keywords: kbprb kbpending KB325159

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.