Shade Posted May 28, 2003 Posted May 28, 2003 I am writing a plug-in to another program in the form of a dll with VC++ .NET. Because I didn't want to have to start the host program every time I changed something, I developed the GUI part of the plug-in separately as a console-application. Now when I moved my GUI back to the dll I get compile errors with GetCurrentDirectory and SetCurrentDirectory and I have no idea why. Code-snippets: String* path = Directory::GetCurrentDirectory(); Directory::SetCurrentDirectory(myPath); My compile errors: error C2039: 'GetCurrentDirectoryA' : is not a member of 'System::IO::Directory' D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of 'System::IO::Directory' error C2660: 'GetCurrentDirectoryA' : function does not take 0 parameters error C2039: 'SetCurrentDirectoryA' : is not a member of 'System::IO::Directory' D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of 'System::IO::Directory' error C2664: 'SetCurrentDirectoryA' : cannot convert parameter 1 from 'System::String __gc *' to 'LPCSTR' Cannot convert a managed type to an unmanaged type If anyone could tell me why this happens I would be ever grateful. Other System::IO::Directory functions seem to work. Quote
Erk1024 Posted March 2, 2006 Posted March 2, 2006 Okay, this is evil. What happened is that you have included an (unmanaged) windows header file that has a macro defined like this #define SetCurrentDirectory(...) SetCurrentDirectoryA() The same thing happens with calls to MessageBox. The solution is to undef the macros: #undef MessageBox #undef SetCurrentDirectory I am writing a plug-in to another program in the form of a dll with VC++ .NET. Because I didn't want to have to start the host program every time I changed something, I developed the GUI part of the plug-in separately as a console-application. Now when I moved my GUI back to the dll I get compile errors with GetCurrentDirectory and SetCurrentDirectory and I have no idea why. Code-snippets: String* path = Directory::GetCurrentDirectory(); Directory::SetCurrentDirectory(myPath); My compile errors: error C2039: 'GetCurrentDirectoryA' : is not a member of 'System::IO::Directory' D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of 'System::IO::Directory' error C2660: 'GetCurrentDirectoryA' : function does not take 0 parameters error C2039: 'SetCurrentDirectoryA' : is not a member of 'System::IO::Directory' D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\vcclr.h(15) : see declaration of 'System::IO::Directory' error C2664: 'SetCurrentDirectoryA' : cannot convert parameter 1 from 'System::String __gc *' to 'LPCSTR' Cannot convert a managed type to an unmanaged type If anyone could tell me why this happens I would be ever grateful. Other System::IO::Directory functions seem to work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.