Microsoft KB Archive/888267

= You may receive an &quot;Error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'&quot; error message when you use the ResourceManager class in Visual C++ .NET 2003 =

Article ID: 888267

Article Last Modified on 1/12/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition

-





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\ \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:   Add code that is similar to the following to your project. Add this code before your managed code that uses the ResourceManager class.  Add code that is similar to the following to your project. Add this code after your managed code that uses the ResourceManager class.
 * 1) ifdef GetObject
 * 2) pragma message(&quot;Undefine the GetObject function for your managed code.&quot;)
 * 3) pragma push_macro(&quot;GetObject&quot;)
 * 4) undef GetObject
 * 5) endif 
 * 1) ifndef GetObject
 * 2) pragma message( &quot;Redefine the GetObject function to the unmanaged code definition.&quot;)
 * 3) pragma pop_macro(&quot;GetObject&quot;)
 * 4) endif 



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



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

Keywords: kbbug kbnofix KB888267

-

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

© Microsoft Corporation. All rights reserved.