ImageMan.Net Twain
TWAIN 1.9 and 2.1 Support
See Also Send Feedback on this topic
ImageMan.Net Twain > Getting Started > TWAIN 1.9 and 2.1 Support

Glossary Item Box

ImageMan.Net Twain supports both the TWAIN 1.9 and 2.1 specifications.  The recently released TWAIN version 2.1 specification offers support for 32 bit and 64 bit operating systems (including Windows 7).  Due to the architecture of the TWAIN support for 64 bit applications it will only support 64 bit TWAIN drivers.  As of now there are not many, if any, true TWAIN version 2.x 64 bit drivers that we are aware of.  This means that applications that must support TWAIN should continue to run as 32 bit applications for compatibility with the most installed scanner drivers. This limitation is a part of TWAIN and not specific to the ImageMan.Net Twain toolkit.  So from a practical standpoint until manufacturers start producing 64 bit drivers it’s not practical to have 64 bit scanning applications.


Note that some manufacturers state they have 64 bit drivers for 64 bit operating systems but in actuality they just have 32 bit TWAIN 1.9 drivers that run on 64 bit operating systems. These are not the same as a true TWAIN Version 2.x 64 bit driver.

 

TWAIN 1.9 Data Source Manager

The TWAIN data source manager (DSM) is a shared library responsible for communicating with imaging devices (like scanners).  The TWAIN 1.9 DSM is a dynamic linked library file called twain_32.dll located in \Windows.  This file contains the programming commands necessary to control 32 bit TWAIN scanner drivers.  It is designed to interact with 32 bit applications and data sources only.  

 

Unlike prior Microsoft operating systems, the TWAIN DSM (Data Source Manager) is not installed on Windows Server 2008 installations. In applications using the ImageMan.Net Twain controls this will cause a System.DllNotFoundException to be generated when a TwainControl method is called.  Applications can query the TwainInstalled property of the TwainControl to determine if the Twain DSM is installed. If it isn't then the application should disable scanning otherwise it will encounter the exception listed above when calling the methods of the TwainControl class.

You can add the TWAIN DSM by installing the Desktop Experience component from the Windows Server 2008 server configuratiom tool. That will install the twain_32.dll file on the system. Optionally you could just copy twain_32.dll from another system into the \Windows directory


Be advised that some manufacturer's software may install a duplicate or out of date version of twain_32.dll in the \Windows\System32 directory.  If your clients experience unexpected scanning issues, please check and remove the twain_32.dll found in the System32 directory.

TWAIN 2.1 Data Source Manager

The new TWAIN 2.1 DSM is a shared library called twaindsm.dll.  There are two versions of this file - 32 bit and 64 bit.  On a 32 bit operating system, the 32 bit version of the file should be installed under C:\Windows\System32.  On a 64 bit operating system, the 32 bit version of the file needs to be installed in the C:\Windows\SysWOW64 directory.  Finally, on a 64 bit operating system, the 64 bit version of the file needs to be located in the C:\Windows directory.

 

Unlike the TWAIN 1.9 DSM, the TWAIN 2.1 DSM is not installed on any Windows operating systems by default.  It is up to you to install the TWAIN 2.1 DSM on your development and client's computers.  You can download the TWAIN 2.1 DSM from the TWAIN organization: http://sourceforge.net/projects/twain-dsm/files/

 

Which TWAIN Version is in Use?

You can use the new TwainControl property TwainInstalled to determine if the user's computer has a TWAIN DSM installed and the UseTwainVersion property to determine which one.  The UseTwainVersion property can also be used to set the version of the TWAIN DSM to use on a client's computer.

 

The following code example demonstrates how to test if a TWAIN DSM is installed on a computer and how to determine which one is currently set as the default DSM. 

 

If both TWAIN 1.9 and 2.1 DSM files are installed on the computer, UseTwainVersion defaults to DTI.ImageMan.Twain.TwainVersion.Version2.

 

C# Copy Code
if (this.twainControl1.TwainInstalled)
{
    switch (this.twainControl1.UseTwainVersion)
    {
        case DTI.ImageMan.Twain.TwainVersion.Version19:
            MessageBox.Show("Twain version 1.9 installed");
            break;
        case DTI.ImageMan.Twain.TwainVersion.Version2:
            MessageBox.Show("Twain version 2.x installed");
        break;
    }
}

 

Visual Basic Copy Code
If Me.TwainControl1.TwainInstalled Then
    Select Case Me.TwainControl1.UseTwainVersion
        Case DTI.ImageMan.Twain.TwainVersion.Version19
            MessageBox.Show("Twain version 1.9 installed")
            Exit Select
        Case DTI.ImageMan.Twain.TwainVersion.Version2
            MessageBox.Show("Twain version 2.x installed")
            Exit Select
    End Select
End If

 

See Also