Library not initialized

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Library not initialized

Post by BillG »

I am running 32 bit version of VS 2008 on Windows 7 64 bit machine. I am still using the Vintasoft 5 sdk because I don't want to update the client until next week. When I run the software on my development machine and try to scan I get "library not initalized". The error occurs on the vsTwain1.StartDevice() line. Here is the code snippet. It worked fine prior to moving to the Windows 7 64 bit machine on a Vista 32 bit machine. I am using the net 2.0 86x vstwain.dll.

Code: Select all

           vsTwain1.StartDevice();
                    vsTwain1.ShowUI = false;
                    if (vsTwain1.SelectSource())
                    {
                        vsTwain1.DisableAfterAcquire = true;
                        vsTwain1.MaxImages = 1;
                        vsTwain1.AutoCleanBuffer = true;
                        vsTwain1.OpenDataSource();
                        vsTwain1.PixelType = PixelType.BW;
                        if (vsTwain1.FeederPresent)
                        {
                            string dirPath = "q:\\EmployerDocuments\\" + myController.CurrentEmployer.Office + "\\";
                            string dateString = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00");
                            RelatedDocumentType rdType = (RelatedDocumentType)ScanItemTypeComboBox.SelectedItem;
                            string docDesc = rdType.DocumentTypeDesc;
                            string filePath = dirPath+myController.CurrentEmployer.EmployerId.ToString() + docDesc + dateString + ".pdf";
                            Int32 numOfPages = Int32.Parse(NumberOfPagesTextBox.Value.ToString());
                            vsTwain1.FeederEnabled = true;
                            vsTwain1.AutoFeed = true;
                            vsTwain1.XferCount = 1;
                            vsTwain1.PdfMultiPage = true;
                            if (vsTwain1.FeederLoaded)
                            {
                                vsTwain1.ShowIndicators = true;
                                while (vsTwain1.AcquireModal())
                                {
                                    try
                                    {
                                        if (pictureBox1.Image != null)
                                        {
                                            pictureBox1.Dispose();
                                            pictureBox1.Image = null;
                                        }
                                        pictureBox1.Image = vsTwain1.GetCurrentImage();
                                        vsTwain1.SaveImage(0, filePath);
                                    }
                                    catch (TwainException ex)
                                    {
                                        if (vsTwain1.ErrorCode != Vintasoft.Twain.ErrorCode.None)
                                            MessageBox.Show(vsTwain1.ErrorString);
                                        else
                                            MessageBox.Show(ex.Message);
                                    }
                                }
                                Int32 docTypeId = Int32.Parse(rdType.DocumentTypeId.ToString());
                                myController.SaveScannedRecord(docTypeId, filePath, DescriptionTextBox.Text.ToString(), numOfPages);
                                vsTwain1.StopDevice();
                                MessageBox.Show("Scan completed.");
                            }
                        }
                    }
                    DescriptionTextBox.Text = string.Empty;
                    NumberOfPagesTextBox.Value = 1;
                    PopulateDocumentsGrid();
                    this.Cursor = Cursors.Arrow;
                }
                catch (Exception ex)
                {
                    if (vsTwain1.ErrorCode != Vintasoft.Twain.ErrorCode.None)
                        MessageBox.Show(vsTwain1.ErrorString);
                    else
                        MessageBox.Show(ex.Message);
                }
            } 
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

Re: Library not initialized

Post by Alex »

Hello Bill,

You can compile your application with version 6.0 and earlier of VintaSoftTwain.NET SDK in "Any CPU" mode and your application will:
  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • NOT work in x64 systems
You can compile your application with version 6.0 and earlier of VintaSoftTwain.NET SDK in "x86" (WOW) mode and your application will:
  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • work in x64 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
You can compile your application with version 6.0 and earlier of VintaSoftTwain.NET SDK in "x64" mode and your application will:
  • NOT work in x32 systems
  • NOT work in x64 systems

You can compile your application with version 7.0 of VintaSoftTwain.NET SDK in "Any CPU" mode and your application will:
  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • work in x64 systems with TWAINDSM.DLL (x64)
You can compile your application with version 7.0 of VintaSoftTwain.NET SDK in "x86" (WOW) mode and your application will:
  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • work in x64 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
You can compile your application with version 7.0 of VintaSoftTwain.NET SDK in "x64" mode and your application will:
  • NOT work in x32 systems
  • work in x64 systems with TWAINDSM.DLL (x64)
We recommend use "x86" mode because all scanners have x32 TWAIN drivers but only new and professional scanners have native x64 TWAIN drivers.

Best regards, Alexander
BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Library not initialized

Post by BillG »

I am using the 32 bit version of Visual Studio 2008 and I only have the choice of any cpu. How do I set it up to use 86x (WOW) mode?

Bill
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

Re: Library not initialized

Post by Alex »

You can set the platform target property to 'X86' for your VB or C# projects as follows:

For C# Projects:
  • Right click the project in the solution explorer and open 'properties'
  • Choose the Build tab
  • Set the Platform Target property to 'X86'
For VB Projects:
  • Right click the project in the solution explorer and open 'properties'
  • Choose the Compile tab
  • Press the Advanced Compile Options... button
  • Set the Target CPU property to 'X86'
Post Reply