PRB: "Invalid Procedure Call or Argument" Error Message When You Call the Invalidate Method of Windows Forms Control (326701)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition

This article was previously published under Q326701

SYMPTOMS

When you call the Invalidate method of a Windows Forms control that is hosted on Microsoft Internet Explorer, you may receive following error message:
Error: Invalid procedure call or argument

CAUSE

The control has multiple overloaded Invalidate methods. Because the type libraries do not support multiple methods with the same name, the multiple methods are appended with suffixes such as "_2" and "_3". In this case, the Invalidate method with the signature "void Invalidate()" or "sub Invalidate()" is represented as Invalidate_3(). Depending on the parameters, Internet Explorer cannot resolve the suffix of the Invalidate method automatically.

RESOLUTION

To resolve this problem, use Invalidate_3() instead of the Invalidate() method.

STATUS

This behavior is by design.

MORE INFORMATION


Steps to Reproduce the Behavior

  1. Create a new Windows Control Library project named MyUserControl by using either Microsoft Visual C# .NET or Microsoft Visual Basic .NET . By default, UserControl1 appears in the Designer pane.
  2. Drag a TextBox control from the Toolbox to UserControl1.
  3. On the Build menu, click Build Solution to create MyUserControl.dll.
  4. Open Notepad or any other text editor.
  5. Paste the following code in the text editor:
    <html>
    	<script>
    		function Click() 
    		{	
    			myUserCtl1.Invalidate();
    			window.alert("Success");
    		}
    	</script>
    	<body>
    		<p><b>Custom User Control</b>
    		<br><br>
    		<object id="myUserCtl1"
    			classid="MyUserControl.dll#MyUserControl.UserControl1"
    			height="300" width="300" VIEWASTEXT>
    		</object>
    		<br>
    		<input type="button" value="Button1" onclick="Click()" ID="Button1" NAME="Button1">
    	</body>
    </html>
  6. Save the text file as Testpage.html.
  7. In the root directory of your Web server, create a folder named TestUserControl. For example, the path of your folder may be C:\Inetpub\Wwwroot\TestUserControl.
  8. Copy MyUserControl.dll and TestPage.html in the TestUserControl folder.
  9. Open Internet Explorer, and then type Http://WebServer/TestUserControl/TestPage.html in the address bar, where WebServer is the name of your Web server.
  10. Click Button1. You receive the error message that is described in the "Symptoms" section.
  11. In a text editor, open TestPage.html from the TestUserControl folder.
  12. Change myUserCtl1.Invalidate() to myUserCtl1.Invalidate_3().
  13. Save TestPage.html.
  14. Repeat steps 10 and 11. You receive a success message.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:12/28/2002
Keywords:kbprb kbBrowse kbhtml kbCtrl kbWebForms kbControl KB326701 kbAudDeveloper