Getting a class Not registered 80041054 in a class that is registered

I call CoCreateInstance from unmanaged code to a registered managed class (record HKEY_CLASSES_ROOT \ CLSID {xxxxx-xxxxxx-xxxxxx-xxxxx-xxxxxx-xxxxx} exists, and the file is downloaded from another program.

Code below:

    HRESULT hRC;
    CoInitialize(NULL);

    char* sUTProgID = "My.Utilities";

    CLSID UTClassID;
    hRC = CLSIDFromProgID(
        _CW(sUTProgID),             // Pointer to the ProgID
        &UTClassID );               // Pointer to the CLSID
    if ( S_OK != hRC )
    {
        DOTRACE((_T("    CLSIDFromProgID error 0x%X\n", hRC)));
    }
    IUnknown* pUnknown;
    hRC = CoCreateInstance(
    UTClassID,                  // Class identifier (CLSID) of the object
        0,                          // Pointer to whether object is or isn't part of an aggregate
        CLSCTX_ALL,                 // Context for running executable code
        IID_IUnknown,               // Reference to the identifier of the interface
        (void**) &pUnknown);        // Address of output variable that receives the interface pointer requested in riid
    if ( S_OK != hRC )
    {
    //code makes it here with an 80040145 class not registered error
    }

The same code works for another application. The code compiles for x86 and runs on an x86 machine.

EDIT: Windows XP, , UAC . ClassID, . ProcMon, , , : InProcServer32 - InProcServerx86 - LocalServer32 - InProcHandler32 - AppId - InProcServer32\ThreadingModel - InProcServer32\1.0.0.0 - InProcServer32\1.0.0.0\assembly - InProcServer32\1.0.0.0\ - InProcServer32\1.0.0.0\class - InProcServer32\1.0.0.0\RuntimeVersion - InProcServer32\CodeBase - ( )

GAC, DLL.

CLIENT.EXE 1092 RegQueryKey HKCR\CLSID {...} : CLIENT.EXE 1092 RegOpenKey HKCR\CLSID {...}\InprocHandler NAME NOT FOUND : CLIENT.EXE 1092 RegCloseKey HKCR\CLSID {9935FEE6-39FD-4EF0-87DB-8372B0992610} CLIENT.EXE 1092 RegOpenKey HKLM\Software\Policies\Microsoft\Windows\ : CLIENT.EXE 1092 CreateFile LogFile.txt

, , .

EDIT2: Dll :

            Assembly asm = Assembly.LoadFile(dll_name);
            RegistrationServices regAsm = new RegistrationServices();
            bool bResult = regAsm.RegisterAssembly(asm,   AssemblyRegistrationFlags.SetCodeBase);

EDIT3: CorFlags.exe () DLL-:

 Version   : v2.0.50727
 CLR Header: 2.5
 PE        : PE32
 CorFlags  : 11
 ILONLY    : 1
 32BIT     : 1
 Signed    : 1

EXE, DLL-:

 Version   : v1.1.4322
 CLR Header: 2.0
 PE        : PE32
 CorFlags  : 9
 ILONLY    : 1
 32BIT     : 0
 Signed    : 1
+4
1

EXE...

CLR. EXE .NET 1.1 CLR 1.1. DLL, CLR v2, .NET 2.0 3.5

.config, CLR. , .exe somefile.exe.config, "somefile" .exe:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50757"/>
   </startup>
</configuration>
+4

Source: https://habr.com/ru/post/1525746/


All Articles