Twain Driver cannot be selected

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
HeartWare
Posts: 2
Joined: Fri May 25, 2012 11:26 am

Twain Driver cannot be selected

Post by HeartWare » Fri May 25, 2012 2:07 pm

I am using a Canon 4400F scanner with a suitable Twain driver. The Twain driver works fine in other programs, such as PMView, but in my program, made with GdPicture, I cannot select the driver - I get an error. The log file is as follows:

Code: Select all

#GdTwain Log Start. Version: 651

RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
Start: UnloadSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
End: UnloadSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
Start: OpenSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
DSM 32-bit library loaded: C:\Windows\TWAIN_32.DLL
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
Entry point of the DSM found.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
End: OpenSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
Start: OpenSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
GDTWAIN_Mgr: Start Getting DAT_STATUS
RC:   TWRC_FAILURE
CC:   TWCC_SUCCESS
State: 3
-------------------
GDTWAIN_Mgr: End Getting DAT_STATUS
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 3
-------------------
End: OpenSource.
RC:   TWRC_FAILURE
CC:   TWCC_OPERATIONERROR
State: 3
-------------------
#GdTwain Log Stop.
both when I open it directly using TwainOpenDefaultSource, or if I open it after having called TwainSelectSource.

My code up to that point looks like this:

Code: Select all

	bool opened;
	TwainStatus status = gdi.TwainGetState();
	Debug.WriteLine("Initial status: "+status.ToString());
	bool ok = gdi.TwainCloseSource();
	Debug.WriteLine("Closing: " + ((ok) ? "OK" : "Failed"));
	String defSource = gdi.TwainGetDefaultSourceName(Handle);
	Debug.WriteLine("Default source: \"" + defSource + "\"");
	Debug.WriteLine("Requested source: \"" + source + "\"");
	if (source != "?")
		opened = (source == defSource)
		         	? gdi.TwainOpenDefaultSource(Handle)
		         	: gdi.TwainOpenSource(Handle, source);
	else
	{
		if (!gdi.TwainSelectSource(Handle))
			return -3;
		opened = gdi.TwainOpenDefaultSource(Handle);
	}
	if (!opened)
	{
		Debug.WriteLine("Failed to open!");
		TwainResultCode rc = gdi.TwainGetLastResultCode();
		if (rc != TwainResultCode.TWRC_SUCCESS)
		{
			TwainConditionCode cc = gdi.TwainGetLastConditionCode();
---->>>		MessageBox.Show("ResultCode = " + rc.ToString() + "\nConditionCode = " + cc.ToString(), "TwainOpenDefaultSource");
		}
		return -2;
	}
	status = gdi.TwainGetState();
	Debug.WriteLine("Post-open status: " + status.ToString());
	if (status < TwainStatus.TWAIN_SOURCE_OPEN)
	{
		gdi.TwainOpenSource(Handle, source);
		status = gdi.TwainGetState();
		Debug.WriteLine("Post-post-open status: " + status.ToString());
		if (status < TwainStatus.TWAIN_SOURCE_OPEN)
			return -1;
	}
The marked line is the messagebox that is shown, and the text is:
ResultCode = TWRC_FAILURE
ConditionCode = TWCC_OPERATIONERROR

My DebugOutput is as follows:

First time:
Initial status: TWAIN_PRESESSION
Closing: OK
Default source: "WIA-CanoScan 4400F"
Requested source: "CanoScan 4400F"
Failed to open!

Subsequent times in same session:
Initial status: TWAIN_SM_OPEN
Closing: OK
Default source: "WIA-CanoScan 4400F"
Requested source: "CanoScan 4400F"
Failed to open!

From the log file, it appears that there's a problem with obtaining DAT_STATUS. Is this really necessary for proper functioning, and if not, can I somehow disable this step?

Also, if I use the WIA driver (which I'd rather not - you can't control the parameters such as dpi and colours via the TWAIN interface for this WIA driver), I get a "Server busy" message box (with buttons "Switch to" and "Retry") as soon as I try to do anything with the WIA driver, such as starting a preview, performing the scan or adjusting the scanning parameters, and it is very hard to get rid of this dialog and make the scan begin.

Running Windows 7 64-bit SP1 with a 32-bit C# program, .NET 2.0, compiled using Visual Studio 2008.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Twain Driver cannot be selected

Post by Loïc » Fri May 25, 2012 3:34 pm

Hello,

We can not analysis the problem with the info provided. Please follow this link: viewtopic.php?t=1486

HeartWare
Posts: 2
Joined: Fri May 25, 2012 11:26 am

Re: Twain Driver cannot be selected

Post by HeartWare » Thu May 31, 2012 2:02 pm

I have created a support ticket with full source code that fails to open source.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest