registration free com and Dispatch LPPICTUREDISP

201 Views Asked by At

This is my COM interface:

[id(2)] boolean Init(BSTR User, BSTR Password);
[id(3)] boolean SetBitmap(BSTR szObjectType, IPictureDisp* szBitmap);

The following Init() function works if the COM interface is registered, or else with the application's manifests using Side-by-side Assemblies (sxs).

Init(LPCTSTR User, LPCTSTR Password)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR VTS_BSTR;
    InvokeHelper(0x2, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
         User, Password);
    return result;
}

However the following SetBitmap() function works only if the COM interface is registred!

BOOL SetBitmap(LPCTSTR szObjectType, LPPICTUREDISP szBitmap)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR VTS_DISPATCH;
    InvokeHelper(0x3, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
        szObjectType, szBitmap);
    return result;
}
  • If I use the COM interface configured with the application manifests, the function call fails with error E_UNEXPECTED

  • If I replace VTS_DISPATCH with VTS_BSTR, the function call is successful and works. In this case it looks like the dispatcher can't dispatch the object.

Any idea about what is going on?

2

There are 2 best solutions below

1
On BEST ANSWER

IPictureDisp parameter is not a problem for registration free COM.

What seems to be wrong here is the way you create the manifest XML. If your IDL is defined for the ActiveX DLL, and the library has the actual TLB then your client binary manifest should have the reference and not the DLL's manifest:

<dependentAssembly>
  <assemblyIdentity name='dlgd' type='win32' version='6.0.0.0'
    processorArchitecture='amd64' />
  <file name="dlgd.ocx" hashalg="SHA1">
    <comClass clsid="{guiD}" tlbid="{guiD}" description="sDlg Control"/>
    <typelib tlbid="{guiD}" version="1.0" helpdir=""/>
  </file>
</dependentAssembly>

Also, boolean IDL method result types should normally be HRESULTs instead. There are also other problems (as pointed by others) as well as your real unposted code might have even additional problems. Still, the case as you explained it can work out just fine if you fix the manifest, you can use RegFreeComPictureDisp solution with your code snippets (client, server, IDL, manifest excerpt) as a reference to fix your project (Trac, Subversion).

0
On

finally it was crazy bug: we have CEF(chromiumembedded) component. and it was initialized without CEfApp object. and here is really crazy problem: ActiveX with registration works normally. without it Dispatch problem. after normal CEF initialization (or with disabled CEF initialization)it works in both cases!