Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using c# to build a small test project which will scan a image .Here is my code to do that

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WIA;
namespace Scanner
{
    public class Scanner
    {
        Device oDevice;
        Item oItem;
        CommonDialogClass dlg;
        public Scanner()
        {

                dlg = new CommonDialogClass();
                oDevice = dlg.ShowSelectDevice(WiaDeviceType.UnspecifiedDeviceType, true, false);


        }
        public void Scann()
        {
            dlg.ShowAcquisitionWizard(oDevice);
        }
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
       // [STAThread]
        static void Main()
        {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           Application.Run(new Form1());
       }
    }
}

 private void button1_Click(object sender, EventArgs e)
        {
            Scanner oScanner = new Scanner();
            oScanner.Scann();
            button1.Text = "Image scanned";
            OpenFileDialog dlg = new OpenFileDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = Image.FromFile(dlg.FileName);
            }
        }

But when I try to run the application and click the button I get the following error at this line dlg = new CommonDialogClass();

Creating an instance of the COM component with CLSID {850D1D11-70F3-4BE5-9A11-77AA6B2BB201} from the IClassFactory failed due to the following error: 80070422.

Can anybody suggest me what the issue here is Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
148 views
Welcome To Ask or Share your Answers For Others

1 Answer

http://mahaafifi.blogspot.co.uk/2012/03/iclassfactory-failed-due-to-following.html

"go to windows Adminstrative tools => services => WIA service => enable it and start it"

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...