1

I am trying to execute a C# program on Windows XP (SP3) which references a managed C++ DLL compiled with VS2012. When compiling the C++ DLL, I have set the Platform Toolset to build to Windows XP (using the v110_xp option) and set minimum required version to 5.01 in linker options, and I already installed Visual C++ 2012 Redistributable Package on the Windows XP machine. But it didn't work.

Any idea on this?

hopper
  • 13,060
  • 7
  • 49
  • 53
Nick Sun
  • 141
  • 3
  • 10
  • What means "didn´t work"? Do you have "VS2012 Update 3" installed? ALso you should have installed http://www.microsoft.com/en-us/download/details.aspx?id=30679 and only deplay the release version. – Jochen Kalmbach Aug 05 '13 at 12:58
  • YES,I have installed "VS2012 Update 3" on my develop machine, and have installed "Visual C++ Redistributable for Visual Studio 2012 Update 3" on windows XP – Nick Sun Aug 05 '13 at 13:07
  • In my DLL, only one simple function, print one message. when running on my develop machine (windows 8), it prints the message.But on my windows xp, it does nothing. – Nick Sun Aug 05 '13 at 13:11

1 Answers1

0

As you mentioned Platform Toolset and v110_xp option, I'd risk assuming the question is about an unmanaged C++ DLL. Anyway, try compiling your DLL with the original VS 2012 distribution (no updates) and see if it works. I dealt with a similar issue caused by VS 2012 Update 2, which is described here. You could test each of your dependency DLLs (including VC++ redistributables) with DependencyWalker, to check if any of them is using a Win32 API not implemented by Windows XP. Just do it under XP itself.

noseratio
  • 59,932
  • 34
  • 208
  • 486
  • Thanks for your response. I use Dependency Walker to check my C++ DLL on the Windows XP,and then I find a lot of Win32 APIs, such as "FlsAlloc","FlsFree",etc, in KERNEL32.DLL, are not implemented. What shoud I do? – Nick Sun Aug 06 '13 at 03:07
  • Try linking dynamically to [VC++ runtime library (CRT)](http://msdn.microsoft.com/en-us/library/abx4dbyh(v=vs.110).aspx), see if that helps. In my case, I managed to get rid of all CRT dependency and use pure Win32 API, but that was a very tiny DLL. Another, not so nice option would be to rollback to original VS 2012 version without any updates (or have it installed under a VM just for the purpose of compiling your DLL). – noseratio Aug 06 '13 at 03:34
  • I have set the Runtime Library to "/MDd", and set the Common Language Runtime Library to "/clr". Is it correct? – Nick Sun Aug 06 '13 at 03:56
  • Looks good to me, but check MSVCR110D.DLL with DependencyWalker under XP, too. – noseratio Aug 06 '13 at 04:02
  • KERNEL32.DLL as reference above, which MSVCR110D.DLL and MSVCP110D.DLL depend on , has miss the Win32 APIs. – Nick Sun Aug 06 '13 at 05:13
  • I loaded a 32-bit XP SP3 VM, copied there 32-bit Debug CRT DLLs from VS 2012 Update 3 (msvcp110d.dll and msvcr110d.dll, ver 11.0.51106.1) and verified them with DependencyWalker. They both look good, no missing imports. It appears the original issue [has been fixed](http://blogs.msdn.com/b/vcblog/archive/2013/05/07/fix-visual-studio-2012-update-2-breaks-windows-xp-targeting-with-atl-and-or-statically-linking-mfc.aspx) with VS2012 Update 3. Perhaps, your are dealing with something else here. Please clarify, is your C++ DLL indeed managed or unmanaged? Is it a 32-bit or 64-bit DLL? – noseratio Aug 06 '13 at 09:04
  • I created a simple console managed C++ "Hello, World" app with VS 2013 Update 3 (as generated by the project wizard), the only thing I changed was setting the target to v110_xp. Compiled it and copied into my XP SP3 VM, along with msvcp110d.dll and msvcr110d.dll, and it ran just OK there. Try doing the same. If it runs, at least you'll know your XP OS + .NET runtime is intact. Sorry I can't help any further with this. – noseratio Aug 06 '13 at 10:26
  • 1
    Thanks,Noseratio. I find I made a mistake maybe. Someone said that the managed C++ DLL must compiled into a release version, but I compiled it into a debug version. I will try it. But still thank you sincerely. – Nick Sun Aug 07 '13 at 06:06
  • YES,The managed C++ DLL must compiled into a Release version. – Nick Sun Aug 08 '13 at 05:41