Reputation: 6679
I am a .NET developer with limited experience in C, C++, and C++/CLI.
We have an old program which is still being developed in Visual C++ 6.0, strictly in C (no C++ features). I've been asked to develop a C++/CLI DLL for this application which allows the application to run some routines that were written in .NET. I'm using Visual Studio 2013.
The machine being used to develop the C application is running Windows XP, has .NET 4.0 installed. We have gotten it to link with the C++/CLI DLL and everything compiles fine. However when we run the software, nothing happens. The user interface doesn't show up and there are no error messages. The process just shows up in the Task Manager for an instant, then goes away. Kind of hard to debug when we don't have any error messages. If we comment out the DLL function call, the software works as usual.
We're using good DLL practices such as extern "C" {...}
, __declspec(dllimport)
, __declspec(dllexport)
, deploying msvcr120.dll along with my DLL, etc. We set up a dummy test DLL without C++/CLI support to make sure we are creating DLLs correctly and everything worked fine.
Does this mean it's impossible to use a C++/CLI DLL in an old C program?
EDIT: I got it working on my development PC (Windows 8.1), but not the Windows XP development PC with VC6. On the Windows XP PC the program crashes before it even calls the DLL function.
Upvotes: 0
Views: 281
Reputation: 6679
It turns out this is an operating system issue.
After I noticed that it works just fine on my Windows 8.1 PC, I took a look at my platform toolset settings for the C++/CLI DLL. To get to those, right-click on the project -> Properties -> Configuration Properties -> General. I was targeting "Visual Studio 2013 (v120)" when I should have been targeting "Visual Studio 2013 - Windows XP (v120_xp)". After I changed that setting, the DLL started working on the Windows XP machine.
Upvotes: 0