c# OPC Automation gives 80040154

Abu Sithik picture Abu Sithik · Feb 20, 2012 · Viewed 13k times · Source

I am a .Net developer. New to OPC. When I tried some samples of OPC Client all of them give this error. It seems the DLL is not registered it seems. But I don't know how and where to register this.

error: retrieving the COM class factory for component with CLSID failed due to the following error: 80040154

Even I tried this

regsvr32 Interop.OPCAutomation.dll", 

but it also throws error like

The module "Interop.OPCAutomation.dll" was loaded but the entry-point DllRegisterServeer was not found.
Make sure that "Interop.OPCAutomation.dll" is a valid DLL or OCX file and then try again.

I have gone through so many existing forums. So many of them said to change the Platform Target to x86 and still I am having the same issue. FYI, I can see only see 'Active (Any CPU)' in the Platform option from the top of the Build tab of Project Properties.

Here are my environment details:

.Net 2005
OPCAutomation Weapper
Windows 7 64-bit OS
Dell Inspiron 1525 (I hope this is not a 64bit machine, but my engineer installed 64bit OS somehow).

Please help me.

Thanks in advance!

Answer

guiu picture guiu · Sep 5, 2012

Just in case somebody is dealing with this problem (as I've recently been...) I get through it! After some time, I found out that it's something about the .NET framework running on 64-bit machines. As long as the.NET application works only with 32-bit CLR, we must set .NET framework to load CLR in WOW mode. To do so, type:

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe SetWow

After this you should be able to run the applications.

You can go back and revert .NET Framework as it was before by typing:

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe Set64