views:

14132

answers:

4

I developed a Windows service using C#.NET to generate PDF report. To generate PDF file I am using a third party dll. The application is running in my Windows XP platform. When I deployed the service in Windows Server 2008 64 bit version, I got this error:

Retrieving the COM class factory for component with CLSID {46521B1F-0A5B-4871-A4C2-FD5C9276F4C6} failed due to the following error: 80040154.

I registered the DLL using the regsvr32 command. I able to see this CLSID in the registry. But the problem persists.

What could be the problem?

+15  A: 

It sounds like your service was built against 'Any CPU' causing you errors on 64bit where you are using COM components. You need to build it for 'x86'.

The website is proberbly running as a 32bit process which is why it can use the component. Building your solution against x86 will force your service to run as 32bit.

Stevo3000
Thank You Very Much!
gopal
Mr. Stevo3000 i got the similar problem when i fetching the outlook contacts in my system. it is working fine in my system (local) but when i uploaded in server it is giving the error likeRetrieving the COM Class factory for component with CLSID failed due to the following error:80040154 can u look my question once please :http://stackoverflow.com/questions/2130603/com-components-are-getting-error thank you
Surya sasidhar
+5  A: 

The problem is that the server process is 64 bit and the library is 32-bit and it tries to create the COM component in the same process (in-proc server). Either you recompile the server and make it 32-bit or you leave the server unchanged and make the COM component out-of-process. The easiest way to make a COM server out-of-process is to create a COM+ application - Control Panel -> Administrative Tools -> ComponentServices.

sharptooth
+10  A: 

In VS - project properties - in the Build tab - platform target =X86

Fabrice MARIANADIN
You just saved me a pointless headache.
Babak Naffas
+2  A: 

I ran into a very similar issue.

I needed to use an old 32-bit DLL within a Web Application that was being developed on a 64-bit machine. I registered the 32-bit DLL into the windows\sysWOW64 folder using the version of regsrv32 in that folder.

Calls to the third party DLL worked from unit tests in Visual Studio but failed from the Web Application hosted in IIS on the same machine with the 80040154 error.

Changing the application pool to "Enable 32-Bit Applications" resolved the issue.

Daniel Ballinger