Home › Forums › TWAIN Classic › DSMParent method is freezing
- This topic has 1 reply, 2 voices, and was last updated 10 years, 9 months ago by MarkM.
- AuthorPosts
Hi,
In my code, I am trying to code find out whether scanner is attached to the computer. In case if the scanner is attached, I should enable “Scan” button in my application. In order determine whether Scanner is attached to the machine, I am using the Twain API. Twain API DSMParent is not returning at all. Since I am calling this method from UI thread, my application is freezing. So I should close my application through task manager only. So could anybody help me, what DSMParent API is internaly doing and is there any possibility that this method may freeze?It is freezing only on this machine. In other machines it is working fine without any issues.
Since it is unmanaged code, if I know the internals of DSMParent method, atleast I can try to diagnose some thing. Please let me know either internals of this API or the cause for API not returning.Machine Description:
OS – Windows 7 – 64 Bit
Dll used – Twain_32.dll
Method used: TwRC rc = DSMparent(appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.OpenDSM, ref hwndp);Call Stack where the method frozen:
004ad978 74e79eb2 [NDirectMethodFrameSlim: 004ad978] Liberty.Framework.NetExchangePro.DocumentMgmt.Twain.(appid, IntPtr, Liberty.Framework.NetExchangePro.DocumentMgmt.TwDG, Liberty.Framework.NetExchangePro.DocumentMgmt.TwDAT, Liberty.Framework.NetExchangePro.DocumentMgmt.TwMSG, IntPtr ByRef)
004ad998 156a2f56 Liberty.Framework.NetExchangePro.DocumentMgmt.Twain.(IntPtr)
004ad9c8 156a2ef5 Liberty.Framework.NetExchangePro.DocumentMgmt.Twain.Init(IntPtr)
004ad9cc 0e88b8f2 Liberty.Framework.NetExchangePro.DocumentMgmt.DocumentUpload.(System.Object, System.EventArgs)
004ada70 04f7006d [MulticastFrame: 004ada70] System.EventHandler.Invoke(System.Object, System.EventArgs)
004ada84 5b1846a5 System.Windows.Forms.Form.OnLoad(System.EventArgs)
004adab8 5b184145 System.Windows.Forms.Form.OnCreateControl()
004adac4 5b176d71 System.Windows.Forms.Control.CreateControl(Boolean)
004adb00 5b176b74 System.Windows.Forms.Control.CreateControl()
004adb18 5b183008 System.Windows.Forms.Control.WmShowWindow(System.Windows.Forms.Message ByRef)
004adb54 5b178966 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)Howdy…
TWAIN_32.DLL is proprietary, it’s also really old. The TWAIN Working Group maintains a newer, fully plug compatible open source version of the Data Source Manager. You can find it here: http://sourceforge.net/projects/twain-dsm
The file is named TWAINDSM.DLL, and it is placed into C:WindowsSystem32. You can download the source code from the same site and build a debug copy, and examine what is happening when you’re issuing commands from your application.
The only change you need to make to your application is to link to or load TWAINDSM.DLL instead of TWAIN_32.DLL. I’m not sure if the framework you’re using will let you do this. If not, you may want to contact them about adding it as an option.
If that’s not an option, then I recommend backing up your system, and then going into C:WindowsTWAIN_32. Check to see how many TWAIN drivers you have installed. If it’s more than one, then move all but one from out of the TWAIN_32 directory, and see if there is still a problem. Do this for each driver. You may be running into an issue with one of the drivers, and this can help spot the one causing the trouble.
(good luck)
— Mark
- AuthorPosts