Need assistance for DocumentInageSDK11.05

Document Imaging SDK,
Image SDK,
TIFF SDK,
Annotation SDK,
Cover Page Generator

Moderator: Technical Support Team

Need assistance for DocumentInageSDK11.05

Postby Srinu » Thu May 05, 2011 11:27 pm

Hi,

In our project we need Scanning functionalty for that we choose ypur product DocumentImageSDK11.05.
I downloaded the trail version.I am developing sample scanning application using DocumentImageSDK11.05.

but it is giving exception System.Windows.Forms.AxHost+InvalidActiveXStateException.
why am getting this exception. clarify my doubt.


I am attaching sample application. So please give me assistance.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Runtime.InteropServices;


namespace ScanningApp
{
    public partial class ScanningWindow : Form
    {
        public static ScanningWindow parentWindow;
        private System.ComponentModel.IContainer components;
        private AxBITWAINLib.AxBiTwain BiTwain;
        private AxBIADVPRNLib.AxBiAdvPrn BiAdvPrn;
        private MenuStrip menuStrip1;
        private ToolStripMenuItem fileToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem selectScannerToolStripMenuItem;
        private ToolStripMenuItem scanToolStripMenuItem;
        private AxBIPRINTLib.AxBIPrint BIPrint1;
        [DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi)]
        private static extern int SendMessage(int hwnd, int message, int lparam, int wparam);
        [DllImport("kernel32", EntryPoint = "GlobalFree", CharSet = CharSet.Ansi)]
        private static extern int GlobalFree(int handle);
        public static int documentcount; // static var which keeps track of the document count

        /// <summary>
        /// Constuctor
        /// </summary>
        public ScanningWindow()
        {
            parentWindow = this;
            InitializeComponent();
            documentcount = 0;
        }

        /// <summary>
        ///  Clean up any resources being used
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScanningWindow));
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.selectScannerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.scanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.BiTwain = new AxBITWAINLib.AxBiTwain();
            this.BiAdvPrn = new AxBIADVPRNLib.AxBiAdvPrn();
            this.BIPrint1 = new AxBIPRINTLib.AxBIPrint();
            this.menuStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.BiTwain)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.BiAdvPrn)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.BIPrint1)).BeginInit();
            this.SuspendLayout();
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(413, 24);
            this.menuStrip1.TabIndex = 0;
            this.menuStrip1.Text = "menuStrip1";
            //
            // fileToolStripMenuItem
            //
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.selectScannerToolStripMenuItem,
            this.scanToolStripMenuItem});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
            this.fileToolStripMenuItem.Text = "File";
            //
            // selectScannerToolStripMenuItem
            //
            this.selectScannerToolStripMenuItem.Name = "selectScannerToolStripMenuItem";
            this.selectScannerToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
            this.selectScannerToolStripMenuItem.Text = "Select Scanner";
            this.selectScannerToolStripMenuItem.Click += new System.EventHandler(this.selectScannerToolStripMenuItem_Click);
            //
            // scanToolStripMenuItem
            //
            this.scanToolStripMenuItem.Name = "scanToolStripMenuItem";
            this.scanToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
            this.scanToolStripMenuItem.Text = "Scan";
            //
            // BiTwain
            //
            this.BiTwain.Enabled = true;
            this.BiTwain.Location = new System.Drawing.Point(0, 0);
            this.BiTwain.Name = "BiTwain";
            this.BiTwain.Size = new System.Drawing.Size(75, 23);
            this.BiTwain.TabIndex = 0;
            //
            // BiAdvPrn
            //
            this.BiAdvPrn.Enabled = true;
            this.BiAdvPrn.Location = new System.Drawing.Point(0, 0);
            this.BiAdvPrn.Name = "BiAdvPrn";
            this.BiAdvPrn.Size = new System.Drawing.Size(75, 23);
            this.BiAdvPrn.TabIndex = 0;
            //
            // BIPrint1
            //
            this.BIPrint1.Enabled = true;
            this.BIPrint1.Location = new System.Drawing.Point(0, 0);
            this.BIPrint1.Name = "BIPrint1";
            this.BIPrint1.Size = new System.Drawing.Size(75, 23);
            this.BIPrint1.TabIndex = 0;
            //
            // ScanningWindow
            //
            this.ClientSize = new System.Drawing.Size(413, 278);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "ScanningWindow";
            this.Text = "ScanningWindow";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.BiTwain)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.BiAdvPrn)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.BIPrint1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void selectScannerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ds;
            ds = BiTwain.GetCurrentDS();

            if (BiTwain.ErrorCode == (int)BITWAINLib.enumErrorCodes.TW_OK)
            {
              // Here i am getting Error(System.Windows.Forms.AxHost+InvalidActiveXStateException.)
                BiTwain.Action = (short)BITWAINLib.enumScanOperations.TWSCAN_TERMINATE;
                BiTwain.Action = (short)BITWAINLib.enumScanOperations.TWSCAN_SELECT;
            }

            else
            {

                // Error
                MessageBox.Show("Error");

            }



           
        }
    }
}




Thanks
SrinivasBabu
Srinu
 
Posts: 2
Joined: Thu May 05, 2011 12:55 pm

Return to Imaging Toolkits



Who is online

Users browsing this forum: No registered users and 1 guest

cron