Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • 2 years later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...