What does BadImageFormatException 0x80131124 (Index not found) mean?

4

My program is occasionally crashing with the following error message:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Index not found. (Exception from HRESULT: 0x80131124)

Some details which may be relevant:

  • C# 4 / .NET 4
  • Windows 7 64 bit OS. EXE is for Any CPU (so it's in 64 bit mode).
  • This is thrown during construction of one of my custom objects. I'm creating this object in a child AppDomain so that I can unload the DLLs which it will load by servicing the incoming request.
  • I see from http://blogs.msdn.com/b/yizhang/ that HRESULT 0x80131124 = CLDB_E_INDEX_NOTFOUND.
  • I've only seen this happen recently (been working on this app for 3 years), and even now, it only occurs when I try profiling the tool using the Red Gate Performance Analyzer or Red Gate Memory Analyzer.

My questions are

  • What does this mean ?
  • What is the 'Index Not Found' ?
  • How do I fix this ?

Thanks very much.

UPDATE

Instead of targeting the EXE for ANY, I forced it to x64. The problem still occurs.

.net
badimageformatexception
asked on Stack Overflow Nov 24, 2011 by gap • edited Jan 25, 2012 by svick

3 Answers

2

Have a look in your solution configuration to make sure all your projects build to the same platform.

The reason for your error is because you have a x86 file trying to load a 64bit dll or Vice versa.

Hope it helps.

answered on Stack Overflow Nov 24, 2011 by Charl
0

You can change your platform target build to X86

answered on Stack Overflow Nov 24, 2011 by Peter PAD
0

There was a similar error due to a broken one .NET Framework. Restore via the utility .NET Framework Repair Tool solved the problem.

answered on Stack Overflow Mar 15, 2021 by Dinariys

User contributions licensed under CC BY-SA 3.0