C# 由于以下错误,IClassFactory失败:80040154类未注册(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG))
我有一个扫描模块,它在我自己的windows 8.1机器上运行良好,但在windows server 2012的IIS上发布代码时,我面临以下错误C# 由于以下错误,IClassFactory失败:80040154类未注册(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG)),c#,asp.net,webforms,C#,Asp.net,Webforms,我有一个扫描模块,它在我自己的windows 8.1机器上运行良好,但在windows server 2012的IIS上发布代码时,我面临以下错误 Creating an instance of the COM component with CLSID {850D1D11-70F3-4BE5-9A11-77AA6B2BB201} from the IClassFactory failed due to the following error: 80040154 Class not registe
Creating an instance of the COM component with CLSID {850D1D11-70F3-4BE5-9A11-77AA6B2BB201} from the IClassFactory failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
我已经成功注册了wiaaut.dll(64位),但我仍然面临同样的问题。
以下是我的代码
private ADFScan _scanner;
public EmpDetail()
{
_scanner = new ADFScan();
}
protected void scan_Doc()
{
_scanner.Scanning += new EventHandler<WiaImageEventArgs>(_scanner_Scanning);
_scanner.ScanComplete += new EventHandler(_scanner_ScanComplete);
ScanColor selectedColor = ScanColor.Color;
int dpi = 150;//some scanners have a problem if you set a lower DPI
_scanner.BeginScan(selectedColor, 150);
//ADFScan will now raise a Scanning event for EACH document scanned.
//then scan complete once there are no more documents to scan.
}
专用ADFScan\u扫描仪;
公共环境管理计划详情()
{
_扫描仪=新的ADFScan();
}
受保护的无效扫描文件()
{
_scanner.Scanning+=新事件处理程序(\u scanner\u Scanning);
_scanner.scanplete+=新事件处理程序(\u scanner\u scanplete);
ScanColor selectedColor=ScanColor.Color;
int dpi=150;//如果设置较低的dpi,某些扫描仪会出现问题
_scanner.BeginScan(selectedColor,150);
//ADFScan现在将为扫描的每个文档引发扫描事件。
//然后,扫描完成,一旦没有更多的文件进行扫描。
}
解决方法
可能的解决方法是将项目的平台从“任意CPU”修改为“X86”(在项目的属性中,构建/平台的目标)
根本原因
VSS Interop是使用32位框架的托管程序集,dll包含32位COM对象。如果您在64位环境中运行此COM dll,将收到错误消息