Search code examples
visual-studio-2010com

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?


Solution

  • 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!