In VS - project properties - in the Build tab - platform target =X86
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.
It sounds like your service was built against 'Any CPU', causing you errors on 64-bit where you are using COM components. You need to build it for x86
.
The website is probably running as a 32-bit process which is why it can use the component. Building your solution against x86
will force your service to run as 32-bit.
You dont have to configure your project properties platform target X86. You can also configure the iis options to work with x86 like that
If you are looking for a way to make this work without recompiling your Any CPU application, here is another potential workaround:
I take no credit for the solution, but it worked for us. Check the source link for more information and other comments.
Source: https://techtalk.gfi.com/32bit-object-64bit-environment/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With