TwainGetSourceCount is 0

Discussions about TWAIN scanning in GdPicture.NET using GdPictureImaging.
Post Reply
wbehning
Posts: 2
Joined: Tue Apr 08, 2014 10:41 pm

TwainGetSourceCount is 0

Post by wbehning » Tue Apr 08, 2014 10:51 pm

I have aquired an application that I need to fix.

It was built with GdPicture.Net 8, version 8.1.0.1

There is a sub as follows:

Code: Select all

    Private Sub fillDevices()
        Dim oGdPictureImaging As New GdPictureImaging

        ' AddHandler oGdPictureImaging.OCRTesseractProgress, AddressOf _ProgressEvent


        For i As Integer = 1 To oGdPictureImaging.TwainGetSourceCount(Me.Handle)
            _dropDevice.Items.Add(oGdPictureImaging.TwainGetSourceName(Me.Handle, i))
        Next

        _dropDevice.SelectedIndex = 0

    End Sub
I always get the exception:
InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.

SelectedIndex = -1, which means that there are no items in the collection.

It is a VB.Net app targeted to the X86 platform.

How do I fix this?

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: TwainGetSourceCount is 0

Post by SamiKharma » Sun Apr 13, 2014 11:33 am

Hi,

You have no Twain sources on your machine, or you have not constructed your application properly. Please have a look at our Twain sample, and try to mimic the behavior.
In any case, your application should handle not finding any sources with out crashing.

Best,
Sami

wbehning
Posts: 2
Joined: Tue Apr 08, 2014 10:41 pm

Re: TwainGetSourceCount is 0

Post by wbehning » Mon Apr 14, 2014 3:43 pm

Yes, I do have a Twain Source on my machine. Like I stated, I aquired this app, I did not build it. Yes I can correct the code so that it dos no craxh, but the fact remains that "oGdPictureImaging.TwainGetSourceCount(Me.Handle)" returns 0.

In fact, if I take the current compiled version of the program, which was built and compile about two years ago, it works on my machine.

I have looked at serveral samples, and our code is mimicing those. Perhaps you can explain why in the compiled version (.exe) that was created two years ago, oGdPictureImaging.TwainGetSourceCount(Me.Handle) returns a positive integer, yet running the uncompiled code returns 0 - on the same machine.

Yes, I have assured that the uncompiled version is using the same exact dlls as the compiled.

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: TwainGetSourceCount is 0

Post by SamiKharma » Mon Apr 14, 2014 3:55 pm

Hi,

We would need more to go on:
1. You did not indicate whether our samples work, if they do and find the source, then it is definitely in the way you built your application. That information isolates the problem a lot.

2. >>Perhaps you can explain why in the compiled version (.exe) that was created two years ago, oGdPictureImaging.TwainGetSourceCount(Me.Handle)
No I cannot because I do not have the exe, nor the code. And in any case, since V8 is legacy code, we cannot really trace it internally.

3. Please follow the steps in the following link, it is a perfect guide for such issues:
viewtopic.php?t=1486

Best,
Sami

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest