System.BadImageFormatException in VS2005
Brian Quigley
Posts: 8
We have an app that is trying to use the SQLDataCompare, SQLCompare, and SQLPackager APIs. When compiling the app we get the following errors:
Exception occurred creating type 'RedGate.SQLDataCompare.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine, Version=5.2.0.40, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Exception occurred creating type 'RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine, Version=5.2.0.32, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Exception occurred creating type 'RedGate.SQLPackager.Engine.PackagerEngine, RedGate.SQLPackager.Engine, Version=5.2.0.49, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Here is what my license file looks like:
RedGate.SQLDataCompare.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine
RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine
RedGate.SQLPackager.Engine.PackagerEngine, RedGate.SQLPackager.Engine
What could be causing these errors?
Exception occurred creating type 'RedGate.SQLDataCompare.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine, Version=5.2.0.40, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Exception occurred creating type 'RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine, Version=5.2.0.32, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Exception occurred creating type 'RedGate.SQLPackager.Engine.PackagerEngine, RedGate.SQLPackager.Engine, Version=5.2.0.49, Culture=neutral, PublicKeyToken=7f465a1c156d4d57' System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Here is what my license file looks like:
RedGate.SQLDataCompare.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine
RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine
RedGate.SQLPackager.Engine.PackagerEngine, RedGate.SQLPackager.Engine
What could be causing these errors?
Comments
The exception message can occur, in one example, if the file is not proper .NET managed code. Maybe removing and re-adding the references will help?
Could it have to do with the fact that I am developing in a 64-bit OS?
Good point. Is there an option in Visual Studio to compile as 32-bit code?
I'm in a similar situation running VS 2005 on an x64 machine. Building a x86 virtual machine isn't an easy option. Does anyone have a workaround that will support the x64 VS environment?
Thanks.
-Roger
Has the computer got .NET Framework 1.1 installed? I think the csc.exe compiler in 1.1 only supports 32-bit code. I guess that on 2.0, the default is going to be 64 on a 64-bit machine.