Error 2 error C2872: 'IDataObject'

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Error 2 error C2872: 'IDataObject' : ambiguous symbol C:\Archivos de
programa\Microsoft Visual Studio 8\VC\PlatformSDK\include\objidl.h 7408

this is the error i got by mix managed and unmanaged code
all i do to get this is this

#include "frmUsrPass.h" //this is managed code, no problem
#include "client.cpp" // this is unmanaged code
#include "\utils\utils.h" // this too


#pragma once

namespace SknrF {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::Drawing;
using namespace System::Net;
using namespace System::Net::NetworkInformation;


.....


}

if i put between /* */ client and utils, i can compile the project, but if
not i got the error, i googled and find just this as possible solution

Move all 'using namespace XXXX' from .h to .cpp
http://www.daniweb.com/techtalkforums/showthread.php?p=152302

but it doesn't works, and this

Both the .NET Windows Forms and COM define an IDataObject interface that are
distinct. You should fully qualify this interface. If you mean to use the
...NET "version" of the IDataObject interface, use
System::Windows::Forms::IDataObject.

at http://www.dotnet247.com/247reference/msgs/43/218228.aspx

but how can i select just one IDataObject?? what setting is this??


Thanks!!!
 
Rick said:
Both the .NET Windows Forms and COM define an IDataObject interface that are
distinct. You should fully qualify this interface. If you mean to use the
..NET "version" of the IDataObject interface, use
System::Windows::Forms::IDataObject.

at http://www.dotnet247.com/247reference/msgs/43/218228.aspx

but how can i select just one IDataObject?? what setting is this??

Try to #include the unmanaged unit before the managed one. Try to put
#include <ObjIdl.h> right after the line #include "stdafx.h". Avoid
importing namespaces into the global namespace from header files.

Your problem can easily be reproduced with these 2 lines:

using namespace System::Windows::Forms;
#include <ObjIdl.h>

The solution, of course, is to either change the order of the two lines,
or to not pollute the global namespace by importing stuff to it.

Tom
 
Back
Top