In the project development, in order to make C# call the original C++ developed OLE interface program, the following method was adopted to establish C++CLI project as an intermediate DLL, with the following advantages:
(1) on the one hand, he can better use C++ to access OLE API functions, and the original C++ development of OLE programs better combination;
(2) on the other hand, C# can easily reference C++CLI DLL, so that the implementation of C# code on the old version of OLE program calls quickly;
(3) low coupling, easy to test, about the correctness of OLE interface and C++CLI, you can independently set up a test project to test.
Therefore, C# projects utilize the invocation relationship of C++ OLE as follows:
C # = = & gt; > > C + + the CLR = = & gt; > > C + +, OLE
Problem 2.
In the real project, the OLE program is developed by another TEAM, we just call it. But during the testing process, the call to OLE interface in the latest test environment failed. Debug finds that the C++CLI failed to initialize the specified OLE program when calling the OLE interface with the error code 0x80040154, which means the following:
OLE error code 0x80040154. Class is not registered.
The main online solution is to call the RegSVR32 command to register your program. The purpose of registration is to establish the mapping relationship between ProgramID and CLSID in the registry. In my understanding, ProgramID is equivalent to our name. When we use the API to call the COM/OLE interface, we pass a plain string called ProgramID, and the API internally operates on the CLSID based on the mapping stored in the registry. There is a subkey in the registry with CLSID as key and its name is LocalService32. The corresponding key value of this key stores the local full path of the final OLE program. Finally, it is found that this key value in our test environment is wrong and does not point to the real OLE program path, thus causing failure in the initialization of OLE program. Given the wrong program path, the loader must fail.
3. Solutions
Modify the CLSID stored in the OLE program full path.
Read More:
- Registering in Windows10 regsvr32 xxx.ocx reported an error but the call to DIIRegisterServer failed with error code 0x80040200…
- Microsoft OLE DB Provider for SQL Server error & #x27;80040e4d & #x27;
- the module was loaded but the call to DllRegisterServer failed with error code 0x80020009
- The solution of GDB code designed problem in Mac OS X
- module ‘win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9‘ has no attribute ‘CLSIDToClassMa
- Solve geforce error code with super full solution CODE:0x0003 Problem approach
- Unable to register the DLL/OCX: RegSvr32 failed with exit code 0x3 My solution
- Solution to “error code is 0x4001” when Intel SGX is running
- Geforce experience appears something went wrong error code 0x0003 error code solution
- BarTender operation encountered the problem of “OLE DB encountered error 0x80004005”
- [Transfer] mdt wds deployment windows Litetouch deployment failed, Return Code = -2147467259 0x80004005 solution…
- OSD deployment failure code (0x00000001) 0x80004005
- Cannot call the same level library solution in pychar
- Call Excel to report an error (the exception comes from HResult: 0x80010105 (RPC)_ SERVERFAULT))
- RuntimeError: Expected hidden[0] size (x, x, x), got(x, x, x)
- Solution to garbled code problem after importing project in eclipse
- [-] handler failed to bind to x.x.x.x: Port troubleshooting
- The solution of red X in eclipse error pages
- com.docker.osx.hyperkit.linux failed to start Exit code 1
- 0xc0000005: solution to access conflict when writing to location 0x00000000