You may receive an "Error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'" error message when you use the ResourceManager class in Visual C++ .NET 2003 (888267)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2003)

SYMPTOMS

You use Microsoft Visual Studio C++ .NET 2003 to create a Microsoft Windows Forms-based project that creates an instance of the ResourceManager class. When you build the project, you may receive an error message that is similar to the following:
c:\Documents and Settings\UserName\My Documents\Visual Studio Projects2\Listbox\Form1.h(100) : error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager' stdafx.cpp(0) : see declaration of 'System::Resources::ResourceManager'

CAUSE

This problem occurs because a #define statement in the Windows.h header file of the Windows Form changes the name of the GetObject function to GetObjectA or to GetObjectW.

The #define statement is applied to the GetObject function of the ResourceManager class. However the .NET Framework does not use the A and W naming convention. Therefore, you experience this problem.

Sometimes, function names and class names are the same in managed code and in unmanaged code. For example, your code may contain both the MessageBox function and the MessageBox class.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, follow these steps:
  1. Add code that is similar to the following to your project. Add this code before your managed code that uses the ResourceManager class.
    #ifdef GetObject
    #pragma message("Undefine the GetObject function for your managed code.")
    #pragma push_macro("GetObject")
    #undef GetObject
    #endif
  2. Add code that is similar to the following to your project. Add this code after your managed code that uses the ResourceManager class.
    #ifndef GetObject
    #pragma message( "Redefine the GetObject function to the unmanaged code definition.")
    #pragma pop_macro("GetObject")
    #endif

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

  1. In Microsoft Visual Studio .NET 2003, use Visual C++ .NET to create a new Windows Forms Application project.
  2. In Solution Explorer, right-click the project, point to Add, and then click Add New Item.
  3. Under Categories, expand Visual C++, and then click UI.
  4. Under Templates, click Windows Form (.NET).
  5. In the Name box, type a name for your form, and then click Open.
  6. Add a Button object to the form.
  7. Add an ImageList object to the form. By default, an ImageList object that is named ImageList1 is created.
  8. Click ImageList1, and then click the ellipsis button (...) in the Images cell of the Properties window.
  9. Click Add, and then select an image to use for your button.
  10. Click the button that you added in step 6, and then set the ImageList property in the Properties window to ImageList1.
  11. In the Properties window, set the ImageIndex property to zero.
  12. Click the form, and then click Code on the View menu.
  13. To add the Windows Resource Manager from the .NET Framework, add the following code to the first line of the file.
    #include <Windows.H>
  14. On the File menu, click Save FileName.h.
  15. On the Build menu, click Build Solution. The error message that is mentioned in the "Symptoms" section appears in the Task list.

Modification Type:MinorLast Reviewed:1/12/2006
Keywords:kbnofix kbBug KB888267 kbAudDeveloper