我正在使用c#
构建一个小型测试项目来扫描图像。这是我的代码
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);
}
}
但是当我尝试运行应用程序并单击按钮时,我在此行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.
有人可以告诉我这里的问题是什么 感谢
答案 0 :(得分:0)
http://mahaafifi.blogspot.co.uk/2012/03/iclassfactory-failed-due-to-following.html
“转到Windows管理工具=&gt; services =&gt; WIA服务=&gt;启用它并启动它”
希望这有帮助。