Method TwainOpenSource crashes in Windows 7

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
jrowlen
Posts: 9
Joined: Tue Mar 01, 2011 7:36 pm

Method TwainOpenSource crashes in Windows 7

Post by jrowlen » Tue Mar 01, 2011 8:00 pm

I’m having a problem with GdPicture.NET which I hope you can help me with.

In Windows 7, an unhandled exception occurs when calling the method TwainOpenSource. The user sees an error message saying “vshost32.exe has stopped working”. While debugging in Visual Studio 2008, an unhandled exception occurs indicating an access violation reading from a specific location. The access violation code given is 0xC0000005.

I’ve researched this issue and what is often cited as a probable cause is Windows 7 use of Data Execution Protection (DEP).

I have replicated this problem with GdPicture.NET in one of our in-house Windows applications, as well as with one of your latest sample applications (twain_sample).

System Details:
Toolkit: GdPicture.NET Ver 7.4.2
Device: Fujitsu fi-6230
Twain Driver: TWAINDSM.dll, version 2.1.4.0
Operating System: Windows 7 Enterprise

Code Snippet: This is from your sample vb app twain_sample

Code: Select all

Private Function OpenSelectedSource() As Boolean
        If lstDevices.Items.Count > 0 Then
            Dim ItemIdx As Integer = lstDevices.SelectedIndex

            If ItemIdx >= 0 Then
                Dim Success As Boolean = oGdPictureImaging.TwainOpenSource(Me.Handle, CStr(lstDevices.Items.Item(ItemIdx)))
                If Not Success Then MsgBox("Can't open selected TWAIN device")
                Return Success
            Else
                MsgBox("Please, select a TWAIN device first !")
                Return False
            End If
        Else
            MsgBox("No TWAIN Device available !")
        End If
    End Function
Log:
#GdTwain Log Start. Version: 650

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\SysWow64\TWAINDSM.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
-------------------
GDTWAIN_Mgr: Start Getting DAT_STATUS
RC: TWRC_ENDOFLIST
CC: TWCC_SUCCESS
State: 3
-------------------
GDTWAIN_Mgr: End Getting DAT_STATUS
RC: TWRC_ENDOFLIST
CC: TWCC_SUCCESS
State: 3
-------------------
Start: OpenSource.
RC: TWRC_SUCCESS
CC: TWCC_SUCCESS
State: 3
-------------------

Exact Error Message:
Unhandled exception at 0x76359775 in twain_sample.exe: 0xC0000005: Access violation

I have followed the steps at viewtopic.php?t=1486, but that did not solve the problem.

Have you had other reports of this problem? And do you have a solution?

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

Re: Method TwainOpenSource crashes in Windows 7

Post by Loïc » Tue Mar 01, 2011 8:17 pm

Hi,

Is the same problem occurs if you replace:

Code: Select all

oGdPictureImaging.TwainOpenSource(Me.Handle, CStr(lstDevices.Items.Item(ItemIdx)))
by

Code: Select all

oGdPictureImaging.TwainOpenDefaultSource(Me.Handle)
?

Kind regards,

Loïc

jrowlen
Posts: 9
Joined: Tue Mar 01, 2011 7:36 pm

Re: Method TwainOpenSource crashes in Windows 7

Post by jrowlen » Tue Mar 01, 2011 8:44 pm

Yes, the same error occurs with that code too.

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

Re: Method TwainOpenSource crashes in Windows 7

Post by Loïc » Wed Mar 02, 2011 7:34 pm

Hi,

We encountered similar problems in the past on Windows Vista & Win7 with some HP scanners that we use to develop scanning applications.

All of them have been fixed getting latest TWAIN driver and using latest TWAIN DSM.

Now, I just know that some TWAIN drivers can encounter problem when Data Execution Prevention are turned on for all programs and services. Solutions consists to switch DEP to windows programs & services (default configuration), or to simply switch it OFF.

I can suggest you to ensure yourself that you are using a stable TWAIN driver targeted for the OS on which it is installed.

Kind regards,

Loïc

jrowlen
Posts: 9
Joined: Tue Mar 01, 2011 7:36 pm

Re: Method TwainOpenSource crashes in Windows 7

Post by jrowlen » Sat Mar 05, 2011 1:50 am

I will make sure I have the latest Twain drivers. I don't think disabling DEP is an option though.

jrowlen
Posts: 9
Joined: Tue Mar 01, 2011 7:36 pm

Re: Method TwainOpenSource crashes in Windows 7

Post by jrowlen » Tue Mar 08, 2011 1:31 am

I found a solution. The latest twain dsm (twaindsm-2.1.4) does not work, but version 2.0.9 does.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest