Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIDL2398 error building with Visual Studio 2010 on Windows 2012

I'm seeing a MIDL2398 error every time I try to compile a Visual C++ (Visual Studio 2010) project which uses COM. This project builds perfectly fine on my Windows 7 developer machine and on a Windows Server 2008 build machine, but not on a Windows Server 2012 build machine.

I found this web site about the various MIDL compiler errors: http://blog.yezhucn.com/midl/compiler_errors.htm

But, I tried it's suggestion for MIDL2398, I verified that "midlc.exe" was in the same directory as "midl.exe" and that both were the same version (both are file version: 7.0.555.1 product version: 6.1.7600.16385, from the Windows SDK v7.1).

I'm guessing it has something to do with Windows Server 2012, but I don't know.

Has anyone been able to get the Windows SDK v7.1 MIDL compiler to work on Windows Server 2012? Or, does anyone know of what else might be causing MIDL2398?

like image 880
MikeW Avatar asked Nov 02 '12 21:11

MikeW


2 Answers

I figured out the problem.

I installed the SysInternals suite ( http://technet.microsoft.com/en-US/sysinternals ) on the build server and then used Process Monitor (procmon) to see what MIDL.exe was trying and failing to do.

In my case, it turned out that there was a file at the root of the C: drive named "Program", so the path to this file was "C:\Program". I don't know what or why, but MIDL.exe was doing something with this file. I renamed the file to "Program--MW", and the MIDL2398 error went away.

If anyone else runs into the MIDL2398 error, I recommend that you also use SysInternals' Process Monitor, add a filter for Process Name -- Contains -- midl, run your compiler and examine the Process Monitor log for errors and strange behavior. It worked for me!

like image 72
MikeW Avatar answered Dec 06 '22 13:12

MikeW


On VS2012, the midl error was caused by com0com installer which created the file Program under the C drive. This is messing with the MIDL as mentioned earlier.

The file C:\Program had the following. Just renaming this file to something else, Ex: C:__Program makes Midl happy.

DIALOG: {
SetupOpenInfFile(C:\WINDOWS\system32\com0com.inf) on line 0
ERROR: 2 - The system cannot find the file specified.


} ... 
like image 29
VS2013_2016 Avatar answered Dec 06 '22 13:12

VS2013_2016