A C2871 compiler error occurs when you add a reference to a COM component in managed Visual C++ .NET (820648)
The information in this article applies to:
- Microsoft Visual C++ .NET (2003)
SYMPTOMSYou may use Component Object Model (COM) components from
a Managed C++ application by using the Add Reference feature in Visual C++ .NET
2003. The Add Reference feature creates an interop assembly. You may use using namespace to import the types that are contained in a namespace. However, when you try to
import the namespace, you may receive the following compiler error message: error C2871: 'COM Component namespace' : a namespace with
this name does not exist CAUSEThe namespace of the COM component is nested under the Interop namespace. Refer the Interop namespace before any COM component namespace. When you use the Add Reference
feature, Visual C++ .NET does not put using namespace Interop; in a source file.RESOLUTIONTo resolve the problem, import the Interop namespace, and then import the namespace of the COM component. For
example, if you reference the Microsoft Scripting Runtime library, you can use the following code to resolve the problem:
using namespace Interop;
using namespace Scripting;
STATUS Microsoft
has confirmed that this is a problem in the Microsoft products that are listed
at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 1/6/2006 |
---|
Keywords: | kbtshoot kberrmsg kbide kbNameSpace kbCOMInterop kbprb KB820648 kbAudDeveloper kbAudITPRO |
---|
|