Windows 7 64-bit issue with OCX loading
I have a .NET 3.5 application that is compiled with a configuration with Any CPU. The application is referencing an OCX file with an interop assembly.
When the application is installed on a Windows 7 32-bit everything works fine. When the same appplication is installed on a Windows 7 64-bit, we get an error:
Retrieving the COM class factory for componen开发者_如何学Ct with CLSID {CCB90182-B81E-11D2-AB74-0040054C3719} failed due to the following error: 80040154
Using Process Monitor from SysInternals I could see that on the 32-bit OS the system is trying to load the following registry key.
HKCR\Wow6432node\CLSID\{above CLSID}\InprocServer or
HKCR\Wow6432node\CLSID\{above CLSID}\InprocServer32
which are available and that's why the application works.
On the 64-bit version Windows is looking for
HKCR\Wow6432node\CLSID\{above CLSID}\InprocHandler or
HKCR\Wow6432node\CLSID\{above CLSID}\InprocHandler32
None of them exist.
How can it be made to work on Windows 7 64-bit?
Since it's an InprocServer it runs in calling process context. If the calling process is AnyCPU running on x64 platform it can run only x64 COM components.
So you either need to get x64 version of component or compile your application for x86 platform.
If this COM component would be an Local or Remote server that would work as well...
Sometimes can help the next actions:
create an filexx.bat with
@echo un-register
regsvr32.exe completePathOfOcxOrDllFile -u
@echo register
regsvr32.exe completePathOfOcxOrDllFile -u
@pause
@exit
And, of course, run the bat file as admin (right click file and click in run as admin).
精彩评论