BadImageFormatException using Display

I am running into a BadImageFormatException on step 8 of “Getting started with CVB.Net” (Getting Started with CVB.Net). I made sure that “Prefer 32-Bit” is unchecked and that the correct references are added. However, every time the “Display” from the Toolbox is added, Visual Studio throws the following exception:

Failed to create component 'Display. The error message follows:
‘System.BadImageFormatException: Es wurde versucht, eine Datei mit falschem Format zu laden. (Exception from HRESULT: 0x8007000B) at Stemmer.Cvb.Forms.DisplayLib.CreateDisplay(IntPtr&Handle) at Stemmer.Cvb.Forms.Controls.Display…ctor()’

I was wondering, if anyone else is familiar with this or maybe knows, what I am doing wrong.
Thank you :relaxed:

Unfortunately there is a file missing in the CVB.Net installer (seems like a new dependency crept in and the installer was not updated accordingly). The installer will be updated in due time - in the meantime you can just drop the attached CVFactory.dll to the C:\Windows\SysWOW64 folder and the exception should be gone: (223.5 KB).

For more detail klick the blurred text…

As Visual Studio is always a 32 bit process, it will instantiate the Forms Display from the new CVB.Net API as a 32 bit entity. This display relies on an implementation inside the native CVCDisp.dll - which would not generally be present in a 64 bit installation of :cvb:. Therefore the Bindings Preview installer installs the CVCDisp.dll and - ideally… - all its dependencies to C:\Windows\SysWOW64 where the operating system will be able to find it. If, however, a dependency is missing the DLL resolution will fail to load the CVCDisp.dll from C:\Windows\SysWOW64 and continue searching for an appropriate CVCDisp.dll. It’ll sooner or later encounter the one located in %CVB% and - for lack of a better candidate - try to load it, realize that it’s a 64 bit entity - which causes the System.BadImageFormatException that you’ve seen.

1 Like