Atalasoft Knowledge Base

HOWTO: Scan through Citrix


When a program runs under Citrix/Terminal Services, it is of course running on a server but 'thinks' it is running on a client workstation. The question is - how does scanning work in this emulated environment? Under Windows Terminal Services (WTS) / Remote Desktop (RDP), TWAIN is generally not available: The TWAIN DataSource Manager (DSM) is typically not present at all.

Citrix, starting with Presentation Server 4.0 (PS), provides some level of TWAIN redirection: This means that TWAIN requests by an application are redirected through PS to the client workstation where they are routed to the client's local TWAIN devices. We think that Citrix put significant care and effort into their TWAIN Redirector, unfortunately it works with only some scanners. Several customers have found scanners that work perfectly outside of the Citrix session, but scanning hangs from an application in a Citrix session.

We do not support scanning under Windows Terminal Services / Remote Desktop (WTS/RDP) unless you use a 3rd party TWAIN 'remoting' solution such as RemoteScan. Under Citrix, we encourage customers to experiment if they have specific scanners: Many will work. However, if your scanning code fails inside of Citrix but works outside, we may not be able to resolve the problem.

Code Changes Needed in DotTwain

When scanning through Citrix it's possible that the device ID will change between calls to open the source manager. This will cause the Device objects in Acquisition.Devices to fail when trying to connect.

To work around this, when scanning in Citrix, you must use the Acquisition.CreateDeviceSession method. It will create a new disposable Device object that can be used once and thrown away. For this to work, you must provide a parent for the Acquisition object and call Dispose on the Device when you're finished with the scan.

Attached to this article is an example project showing how to use CreateDeviceSession; both C# and VB projects are provided.

2023-10-27 - Sample app rebuilt to target .NET Framework 4.5.2 instead of .NET Framework 3.5

Original Article:
Q10238 - HOWTO: Scan through Citrix
Last Modified: 6 Months Ago
Last Modified By: Tananda
Rated 3 stars based on 3 votes.
Article has been viewed 2.5K times.
Also In This Category