You are currently offline, waiting for your internet to reconnect

BUG: "Attempt to Access the Method Failed" Error Message When You Use a Reference to the Wrong Microsoft Forms 2.0 Object Library

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

SYMPTOMS
In a Visual Studio .NET project that contains a reference to the Microsoft Forms 2.0 Object Library, you may receive an error message similar to the following:
System.MethodAccessException: "Attempt to access the method failed."
CAUSE
When you use the Add Reference dialog box to add a reference to the Microsoft Forms 2.0 Object Library, you may notice that two entries appear for Microsoft Forms 2.0 Object Library. Both of these entries refer to the FM20.dll file.

You must select the first Microsoft Forms 2.0 Object Library entry in the list because this is the Primary Interop Assembly (PIA) reference. If you select the second Microsoft Forms 2.0 Object Library entry, your application may not behave as expected.
RESOLUTION
To resolve this problem, follow these steps:
  1. In Solution Explorer, right-click the MSForms reference, and then click Remove.
  2. In Solution Explorer, right-click References, and then click Add Reference.

    The Add Reference dialog box appears.
  3. In the Add Reference dialog box, click the COM tab.
  4. In the list of components, click the first entry that is named Microsoft Forms 2.0 Object Library.

    Note This should be the PIA version. If only one Microsoft Forms 2.0 Object Library entry appears in the Add Reference dialog box, and this entry is not the PIA version, you must first install the PIA from the Microsoft Office System 2003 CD-ROM.
  5. Click Select to add the entry to the list of selected components.
  6. Click OK to close the Add Reference dialog box.
  7. In Solution Explorer, click the MSForms reference that you added in step 5. Verify that the Copy Local property is set to False, and that the Path property is pointing to the PIA (as described in the "More Information" section).
  8. Delete the old Interop.MSForms.dll file from the Obj folder that is located your application folder.
MORE INFORMATION
When you use a reference to the PIA version of the Microsoft Forms 2.0 Object Library, you will notice the following properties for the MSForms reference in Solution Explorer:
  • Copy Local: False
  • Path: C:\WINDOWS\assembly\GAC\Microsoft.Vbe.Interop.Forms\11.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.Forms.dll
If the Path property points to a folder in the global assembly cache (GAC), you have the correct (PIA) reference.

If the reference to the Microsoft Forms 2.0 Object Library was added incorrectly (or if the PIA is not installed), the properties of MSForms appear as follows:
  • Copy Local: True
  • Path: C:\MyApplication\obj\Interop.MSForms.dll
Notice that Visual Studio .NET creates a new interop assembly (IA), and then copies it to a folder in your project. If this behavior occurs, you are using the wrong assembly.

If your solution uses the wrong MSForms reference, you may experience problems when you try to use objects from this library. For example: You try to use the FindControl function in an Excel workbook project that was created by using the Visual Studio Tools for the Microsoft Office System. (Typically, you might do this to capture the Click event of a CommandButton control in the worksheet.) If the solution uses the wrong MSForms reference, the Click event of the CommandButton control does not fire when the user clicks the button on the worksheet, although no errors appear to have occurred in the code. If you use an exception handler when you try to assign your CommandButton object, you receive the error message that appears in the "Symptoms" section.
Properties

Article ID: 824009 - Last Review: 01/15/2004 16:26:46 - Revision: 1.5

  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Office Professional Edition 2003
  • Microsoft Visual Studio Tools for the Microsoft Office System
  • kberrmsg kbbug kbpia kbnofix KB824009
Feedback