Support Center

Exception when trying to access TwainControl

Jason Hammond Oct 10, 2011 04:56PM EDT

I purchased the Twain library in 2008 and have been using it in my application. I develope on a x64 computer using Visual Studio 2010 (for the last 13 months) and have not had know issues until today... when I needed to do some more development for scanning.

I am getting the following error when I try to access the TwainControl on the WindowsForm.

"An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"

Is there a know issue with the TwainControl DLL and an x64 computer? Do I need an update? Maybe some Windows 7 update has "broken" your DLL?

Any help on this please...

2 Data Techniques Responses and 2 Community Responses

Up -3 Rated Down
DTI Support  Data Techniques Employee Oct 10, 2011 05:05PM EDT


You nee dot download the IMageMan.Net Twain V 3 components from the My Products page on our website at

The 3.0 component support Twain 2.0 which will get you 64 bit support. One warning however is that if you let your app run as 64 bits rather than forcing it to 32 bits (on a 64 bit OS) then it will only be able to scan from 64 bit scanner drivers of which there are very few available. Your best option is to set the Visual Studio Target CPU to x86 instead of Any CPU and that way your app will be able to use 32 bit twain drivers on a 64 bit OS.

Up 5 Rated Down
Jason Hammond  Data Techniques Employee Oct 12, 2011 02:12PM EDT

I had V 2.8 of ImageMan.Net Twain installed (from previous messages I found this should have been sufficient). I installed V3 "ImNetTwain301.exe" anyway and still get the same error after updating the References.

I changed the Target CPU to x86 and this did seem to fix the scanning issue, but now other pinvoke errors occur from other assemblies (not yours) so I switched it back to "any cpu".

I also reference DTI.ImageMan.dll , DTI.ImageMan.Codecs.dll , and DTI.ImageMan.Core.dll from other parts of the application that handle image processing. Would this cause an issue? They are from "ImageManNet173.exe"

Up 0 Rated Down
Jason Hammond  Data Techniques Employee Oct 12, 2011 02:44PM EDT

Also, looking at my old code notes... I see I ran into similar issues on 10/29/2010. At that time I was developing on my x64 computer and you reissued a new license key. Seems odd that this is occuring again on the same computer. Any ideas?

Up -1 Rated Down
DTI Support  Data Techniques Employee Oct 12, 2011 04:12PM EDT

The Bad Format exception is caused by trying to load a 32 bit assembly into a 64 bit app or vice versa. If you want to support 32 bit Twain drivers with your app on 32 and 64 bit OSes then you will have to build the app for x86 and NOT x64 or AnyCPU.

This has nothing to do with the license key. Also note that if you plan to use ImageMan.Net in a x64 or AnyCPU application then you will need Version 3+. The older versions support only x86 targets.

Thanks for your interest in our products and please let us know if you have any questions.

Data Techniques Support

This question is closed to new answers.

Contact Us