OS Loader lock

Jul 1, 2009 at 5:03 PM

Hi all and gaccettola

I'm getting this error when running the code

Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang

file twIdentity.vb

Friend Function CloseDS() As Boolean
        'DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS (4 only -> 3)

        myTrace.WriteLine("CloseDS", Instrumentation.TraceLevelEnum.Information, _
                          My.Resources.LocalStrings.TwStateChangeRequest)
        Select Case m_parent.TwState
            Case 4
                Dim Rc As Enumerations.ReturnCode = Enumerations.ReturnCode.Failure

                'from Application to Source Manager
                the errors from here >>  Rc = DllImports.twain_32.Identity(m_parent.MsgPump.pOrigin, _
                                                  IntPtr.Zero, _
                                                  Enumerations.DataGroup.Control, _
                                                  Enumerations.DataArgumentTypes.Identity, _
                                                  Enumerations.Message.CloseDs, _
                                                  m_parent.MsgPump.pDest)

 

This causes another problem when I run the code again "The scanner is already in use by another application"

Any idea as to why I'm getting the problem?

Thanks

PQSIK

 


 

Coordinator
Jul 2, 2009 at 12:23 PM

I faintly remember running into that but I don't have any code comments on my internal code branch or in opentwain so it could be that my memory was from another project - it could have even been from the dialogmanager, which would almost make sense.

If you could give me some more information,  are you running the sample guiharness or the sample cmdharness?  are you using vs2005?  what kind of device?

Where in the function (line#) are you getting the exception?  Are you running XP, Vista, 7 etc.?  Do you get the exception often regardless of device, or could it be with only some devices?

 

.

Jul 2, 2009 at 3:42 PM

Thanks for the quick reply gaccettola,

I'm using the guiharness with VS2005

THe scanner is a  Xerox DocuMate 510 -- OneTouch Scanner {DM510}

The error is in twIdentity.vb line# 31

Rc = DllImports.twain_32.Identity(m_parent.MsgPump.pOrigin, _
                                                  IntPtr.Zero, _
                                                  Enumerations.DataGroup.Control, _
                                                  Enumerations.DataArgumentTypes.Identity, _
                                                  Enumerations.Message.CloseDs, _
                                                  m_parent.MsgPump.pDest)

The error happened when I close the scanner settings dialog box

The Dialog Manager known dialogs has nothing, the unknown has 3

Source                     Title                                                                                                           text

cbt                              Xerox DocuMate 510                                                                         The Scanner is already in use by another application.

polling                      Xerox DocuMate 510                                                                          The Scanner is already in use by another application.

polling                      Mhe Scanner is already in use by another application.          blank

I'm I missing something with the dialog manager or dialog rules

 

Thanks

PQSIK

 

Jul 15, 2009 at 11:48 PM

Hi all,

I'm still getting the same error,

any idea as to fix the problem,

Thanks

PQSIK

Mar 7, 2010 at 7:05 PM
Edited Mar 7, 2010 at 7:30 PM

gaccettola

It looks like I cant use all the code because of the error.

I was wondering if I could use some of the code but scan with http://www.dosadi.com/eztwain1.htm EZTWAIN Classic

Thanks

PQSIK

Coordinator
Mar 11, 2010 at 1:42 PM

No, I'm sorry to say that I don't have an idea for a fix - and the worst part is that I'm unable to reproduce the error.  If you can reproduce this with a simulated driver (like the Kodak i30 driver in simulation mode) I should be able to track the issue.

 

Best Regards,

Mar 14, 2010 at 1:23 AM

Hi gaccettola,

I tried GdPicture.net to see if I got the same error and I did.

There is some demo code for Twain acquisition and the code for "Source Setup" opens the scanner UI, I get the error when I click the save button on the scanner UI.

If oGdPictureImaging.TwainGetState < TwainStatus.TWAIN_SOURCE_OPEN Then
            MsgBox("You need to open a source first !")
        Else
            oGdPictureImaging.TwainShowSetupDialogSource(Me.Handle)

End If

I will look for another scanner.

Thanks for all your help.