-1

I'm using this example for scan twain .NET TWAIN image scanner

But when I try running my project on a 64-bit system, its giving me this error:

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

According to many searches that I have made, I found the twaindsm.dll. I tried to import it but the system becomes stuck.

I tried to build the project in 32-bit, and that didn't worked either.

Any help?

LarsTech
  • 80,625
  • 14
  • 153
  • 225
Adir.el
  • 43
  • 2
  • 10
  • 2
    You cannot reference a 32-bit dll within a 64-bit process. Compile your application to be a 32-bit process and you won't get this error. I don't know what exactly you tried but the only other solution is to compile the dll to be a 64-bit dll and reference that. These are your only two solutions. I have to downvote for the lack of research. – Security Hound Oct 16 '12 at 11:29
  • when i tried to compile in 32 bit lot of my "using" made an error when i used build. – Adir.el Oct 16 '12 at 11:38
  • Adir - "that didn't worked either" isn't a good stackoverflow question. If you are using a project you found on another website, first go there and see if you can get help. If you still have a problem and can't get help from the project's authors or users, then (a) research the problem, (b) search on Stack Overflow, and only then, (c) post a specific question with all the facts so others can understand exactly what the problem is. Specifically describe what you did, what you observed, and what you expected. – Spike0xff Oct 16 '12 at 16:16

4 Answers4

1

Twain DLL are for 32 bit system wich basicly wont work on 64 bit.

Flexo
  • 87,323
  • 22
  • 191
  • 272
Adir.el
  • 43
  • 2
  • 10
1

You can find the 64 bit version of the TWAINDSM DLL. While installing your application make sure this DLL is in the same folder as your exe and make sure you load this manager.

In 64 bit systems the default twain32 dll sits under C:\Windows. Hence when the TWAIN app loads this module it loads the 64 bit version. Always the best way to avoid DLL resolution conflicts with TWAIN is to port your DSM as part of it. That way it works everywhere.

  • I have the same problem, I downloaded the 64-bit library. I have no exception but in my source list I have no scanner. The solution provided by Asprise Support works but it's not free to use. How the 64 bits dll works ? – A.Pissicat Sep 21 '18 at 08:34
  • The Twain DSM recursively searches the Twain folders [C:\windows\twain_32] and [c:\windows\twain_64] directories for .ds files [Data source files]. So 32 bit apps will load only 32 bit DS files and same applies for the 64 bit apps. The twain spec provides a very elaborate discussion on this [https://www.twain.org/wp-content/uploads/2016/03/TWAIN-2.2-Spec.pdf] refer to chapter 12. – Preeth Pratheek Sep 21 '18 at 14:28
0

Twain DLL are for 32 bit system wich basicly wont work on 64 bit.

Agree, this is the cause of the problem.

Here is the solution: Access Scanners from 64bit Applications

Asprise Scanning C# VB.NET TWAIN WIA Scan SDK is probably the only scanning library that works for both 64bit and 32bit applications thanks to the innovative patent pending technology and quality implementation.

You may obtain the library from NuGet directly:

enter image description here Install-Package asprise-scan-scanner-twain-wia-api

Here is the documentation to C# VB.NET Twain Scanning Library API.

-1

Change Platform target to x86 from project properties.

C J
  • 1