Article ID: 315946
Article Last Modified on 8/24/2005
APPLIES TO
- Microsoft Visual Studio .NET 2002 Professional Edition
- Microsoft Visual Studio .NET 2002 Enterprise Architect
- Microsoft Visual Studio .NET 2002 Enterprise Developer
- Microsoft Visual Studio .NET 2002 Academic Edition
- Microsoft Visual Studio .NET 2003 Academic Edition
- Microsoft Visual Studio .NET 2003 Enterprise Developer
- Microsoft Visual Studio .NET 2003 Enterprise Architect
- Microsoft Visual Studio .NET 2003 Professional Edition
This article was previously published under Q315946
SYMPTOMS
In Microsoft Visual Studio .NET, when you try to convert the managed parameter constructor std::string& to std::string, you receive the following error message:
RESOLUTION
Change the constructor so that it requires its argument to be copy constructed.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
Steps to Reproduce the Behavior
Create a Managed Extensions for C++ application named Test. Delete the existing code in Test.cpp, and then paste the following sample code:
/* test.cpp*/ #include "stdafx.h" #using <mscorlib.dll> #include <string> public __gc class Hello { public: Hello(std::string arg) {} }; public __gc class There { public: void Something(const std::string &arg) { Hello *hello = new Hello(arg); } }; void main() { There *there = new There(); there->Something("world"); }
- Do one of the following:
- Use the integrated development environment (IDE) to build the project.
-or- - Compile the file in Visual Studio .NET by typing the following at a command prompt: cl /clr /EHsc test.cpp
- Use the integrated development environment (IDE) to build the project.
Keywords: kbbug kbpending kbvs2002sp1sweep KB315946