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), 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 WTS 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, 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.
Some customers have reported difficulty downloading the example attached in this KB system, so here is a link to a dropbox hosted version: