我用c#开发了一个Windows服务。生成PDF报告。要生成PDF文件,我使用第三方dll。应用程序在我的Windows XP平台上运行。当我在Windows Server 2008 64位版本中部署服务时,我得到了这个错误:

检索的COM类工厂 带有CLSID的组件 {46521 b1f - 0 a5b - 4871 - a4c2 fd5c9276f4c6} 由于以下错误导致失败: 80040154.

我使用regsvr32命令注册了DLL。我能够在注册表中看到这个CLSID。但问题依然存在。

有什么问题吗?


当前回答

我发现我的问题与DLL的实际注册有关。

First run "Regedit.exe" from a CMD prompt (I raised it's security level to Administrator, "just in case") then search the Registry (by clicking on "Edit/Find" in the RegEdit menu or by pressing Ctrl+F) for the CLSID showing in the error message which you received regarding the COM class factory. My CLSID was 29AB7A12-B531-450E-8F7A-EA94C2F3C05F. When this key is found, select the sub-key "InProcServer2" under that Hive node and ascertain the filename of the problem DLL in the right hand Regedit frame. showing under "Default". If that file resides in "C:\Windows\SysWow64"(such as C:\Windows\SysWow64\Redemption.dll") then it is important that you use the "C:\Windows\SysWow64\RegSvr32.exe" file to register that DLL from the command line and NOT the default "C:\Windows\System32\RegSvr32.exe" file. So I ran a CMD prompt (under Administrative level control (just in case this level is need required) and type on the command line (in the case of my DLL): C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll the press enter. Close the command window (via "Exit" then Restart your computer (always use restart instead of Close Down then start up, since (strangely) Restart perform a thorough shut down and reload of everything whereas "Shut Down" and Power-Up reloads a stored cache of drivers and other values (which may be faulty). Whenever you register a DLL in the future, remember to use the SysWow64 "RegSvr32.exe" for any DLL stored in the C:\Windows\SysWow64 folder and this problem c(if it is caused by incorrect registration) should not happen again.

其他回答

在我的情况下,我正在生成ms office文件,如word或excel,我运行Win+R并执行dcomcnfg,在DCOM配置中,除了选择office相关的名称项(如名称包含excel或word或office),并打开属性,选择身份选项卡并选择交互式用户。作为这个答案,

我的错误消息显示CLSID {000209FF-0000-0000-C000-000000000046},所以我必须尝试在DCOM配置中找到这个特定的CLSID,它确实存在,我选择它并遵循相同的步骤设置交互用户,然后它就工作了。

我发现我的问题与DLL的实际注册有关。

First run "Regedit.exe" from a CMD prompt (I raised it's security level to Administrator, "just in case") then search the Registry (by clicking on "Edit/Find" in the RegEdit menu or by pressing Ctrl+F) for the CLSID showing in the error message which you received regarding the COM class factory. My CLSID was 29AB7A12-B531-450E-8F7A-EA94C2F3C05F. When this key is found, select the sub-key "InProcServer2" under that Hive node and ascertain the filename of the problem DLL in the right hand Regedit frame. showing under "Default". If that file resides in "C:\Windows\SysWow64"(such as C:\Windows\SysWow64\Redemption.dll") then it is important that you use the "C:\Windows\SysWow64\RegSvr32.exe" file to register that DLL from the command line and NOT the default "C:\Windows\System32\RegSvr32.exe" file. So I ran a CMD prompt (under Administrative level control (just in case this level is need required) and type on the command line (in the case of my DLL): C:\Windows\SysWow64\RegSvr32.exe c:\Windows\SysWow64\Redemption.dll the press enter. Close the command window (via "Exit" then Restart your computer (always use restart instead of Close Down then start up, since (strangely) Restart perform a thorough shut down and reload of everything whereas "Shut Down" and Power-Up reloads a stored cache of drivers and other values (which may be faulty). Whenever you register a DLL in the future, remember to use the SysWow64 "RegSvr32.exe" for any DLL stored in the C:\Windows\SysWow64 folder and this problem c(if it is caused by incorrect registration) should not happen again.

听起来你的服务是针对“任何CPU”构建的,导致你在使用COM组件的64位上出现错误。您需要为x86构建它。

该网站可能作为一个32位进程运行,这就是为什么它可以使用该组件。基于x86构建解决方案将迫使您的服务以32位的方式运行。

问题是服务器进程是64位的,而库是32位的,它试图在同一个进程(进程内服务器)中创建COM组件。要么重新编译服务器,使其成为32位,要么保持服务器不变,使COM组件处于进程外。使COM服务器脱离进程最简单的方法是创建一个COM+应用程序-控制面板->管理工具->组件服务。

我没有更改任何编译设置。

只需在AppPool高级设置中设置“启用32位应用程序= True”。

这对我很有效