By the way, I have tried your sample apps. They are also failing with the same error on virtual machine and working well on my development PC.

I think I was able to find out the reason. Please find my thoughts below:

I have just installed drivers for my scanner to the virtual machine but have never attached device. So, I am getting the exception described in my previous post. The following lines from your library which are throwing exception(OpenDSM -> _GetAllSorces
Method):

After I have attached the device, the library works well. It shows 2 "devices" - my scanner and the same one but with WIA interface.

Note, that If I detach device it also works well, shows me my scanner as offline device, so I can manage this situation. So, this error is observed only before first device attach.

So, the main question is this exception thrown in OpenDSM(_GetAllSorces) related to the driver manufacturer or Saraff.Twain.Net really throws such error when we try to initialize Data Source Manager but have not attached devices instead of just having empty
sources collection? What do you think?

DG_CONTROL / DAT_IDENTITY / MSG_GETFIRST

Call

Description

The application may obtain a list of all Sources that are currently available on the system which
match the application’s supported groups (DGs, that the application specified in the
SupportedGroups field of its TW_IDENTITY structure). To obtain the complete list of all available
Sources requires invocation of a series of operations. The first operation uses MSG_GETFIRST to
find the first Source on “the list” (whichever Source the Source Manager finds first). All the
following operations use DG_CONTROL / DAT_IDENTITY / MSG_GETNEXT to get the identity
information, one at a time, of all remaining Sources.
If the application wants to cause a specific Source to be opened, one whose ProductName the
application knows, it must first establish the existence of the Source using the MSG_GETFIRST/
MSG_GETNEXT operations. Once the application has verified that the Source is available, it can
request that the Source Manager open the Source using DG_CONTROL / DAT_IDENTITY /
MSG_OPENDS. The application must not execute this operation without first verifying the
existence of the Source because the results may be unpredictable.

Return Codes

TWRC_SUCCESS
TWRC_FAILURE
TWCC_NODS /* No Sources can be found */
TWCC_LOWMEMORY /* Not enough memory to perform this operation */