?
Solved

Interfaces are not shown in the OLE/COM object viewer

Posted on 2003-03-10
8
Medium Priority
?
379 Views
Last Modified: 2013-11-25
I am following along the example in Chapter 4 of "Developer's Workshop to COM and ATL 3.0" to build coclass server(dll) for the coclass CoCar. The IDL files are as follows. I have registered the Lib ID, App ID and Class ID properly. My client program run perfectly fine with the call to the coclass object via CoGetClassObject(CLSID_CoCar, CLSCTX_INPROC_SERVER...).  However, it fails immediately if I change the call to CoGetClassObject(CLSID_CoCar, CLSCTX_LOCAL_SERVER...). It seems to me that it fails to create the coclass object. I went into the OLE/COM Object viewer and found that the IStats, IEngine and ICreateCar were not shown under the CoCar Object but only IUnknown.  However, they are listed as interfaces in the "View Type Information". Is there any reason why the object viewer doesn't see the interfaces? (The ITypeLib from the type lib viewer is also shown below)

/*=======================================================*/
//Bring in core IDL files
import "oaidl.idl";

//IStats
[object, uuid(9CC47693-E378-49cd-8911-B6617E8A4E9F),
 helpstring("Get info about this car")]
interface IStats : IUnknown
{
     HRESULT DisplayStats();
     HRESULT GetPetName([out, retval] BSTR* petName);
};

//IEngine
[object, uuid(95D6C4A8-2512-4917-9482-1B0F828409B6),
 helpstring("Rev your car & slow it down")]
interface IEngine : IUnknown
{
     HRESULT SpeedUp();
     HRESULT GetMaxSpeed([out, retval] int* maxSpeed);
     HRESULT GetCurSpeed([out, retval] int* curSpeed);
};

//ICreateCar
[object, uuid(BC0CD035-D26D-46b9-9076-C69E800DD854),
 helpstring("This lets you create a car")]
interface ICreateCar : IUnknown
{
     HRESULT SetPetName([in]BSTR petName);
     HRESULT SetMaxSpeed([in]int maxSp);
};

//The library statement
[uuid(869706BC-5467-4cb2-8596-FAE26E0C1623), version(1.0),
 helpstring("CoCar server with TypeLib")]
library CarServer
{
     importlib("stdole32.tlb");
     [uuid(DCC1BA5D-20C7-4f12-8312-D5223914FDE5)]
     coclass CoCar
     {
          [default] interface ICreateCar;
          interface IStats;
          interface IEngine;
     };
};

/*============================================================*/



/*##############################################################*/

// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: CarServerTypeInfo.tlb

[
  uuid(869706BC-5467-4CB2-8596-FAE26E0C1623),
  version(1.0),
  helpstring("CoCar server with TypeLib")
]
library CarServer
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    interface ICreateCar;
    interface IStats;
    interface IEngine;

    [
      uuid(DCC1BA5D-20C7-4F12-8312-D5223914FDE5)
    ]
    coclass CoCar {
        [default] interface ICreateCar;
        interface IStats;
        interface IEngine;
    };

    [
      odl,
      uuid(BC0CD035-D26D-46B9-9076-C69E800DD854),
      helpstring("This lets you create a car")
    ]
    interface ICreateCar : IUnknown {
        HRESULT _stdcall SetPetName([in] BSTR petName);
        HRESULT _stdcall SetMaxSpeed([in] int maxSp);
    };

    [
      odl,
      uuid(9CC47693-E378-49CD-8911-B6617E8A4E9F),
      helpstring("Get info about this car")
    ]
    interface IStats : IUnknown {
        HRESULT _stdcall DisplayStats();
        HRESULT _stdcall GetPetName([out, retval] BSTR* petName);
    };

    [
      odl,
      uuid(95D6C4A8-2512-4917-9482-1B0F828409B6),
      helpstring("Rev your car & slow it down")
    ]
    interface IEngine : IUnknown {
        HRESULT _stdcall SpeedUp();
        HRESULT _stdcall GetMaxSpeed([out, retval] int* maxSpeed);
        HRESULT _stdcall GetCurSpeed([out, retval] int* curSpeed);
    };
};


0
Comment
Question by:UTEK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 8114383

  When you specify CLSCTX_LOCAL_SERVER COM is expecting to load an Exe. Your object is a dll I believe so this will fail.
0
 

Author Comment

by:UTEK
ID: 8148856
But the OLE/COM object viewer should see and display the interfaces no matter it is a dll or exe, right?
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 8153210

 Can you find your GUIDS in the registry?
0
 

Expert Comment

by:tazochai
ID: 8435973
I am following examples from the same book.  I have the same problem.  I can find the GUIDs in the registry.  The only interface showing in the OLE/COM object viewer is IUnknown.  Does anyone else have another suggestion please?
0
 

Accepted Solution

by:
tazochai earned 800 total points
ID: 8436505
Okay now we know what happened!!!
I will credit my coworker with finding this one.

In this book, the *.reg files from the samples are not correct.  Both chapter 3 and 4 are missing the registry entries that will allow the interfaces to be listed in the OLE/COM object viewer.

This is what your carservertypeinfo.reg needs to look like.  Notice that I added the sections HKEY_CLASSES_ROOT\Interface\.  You need to add the GUID of the interface itself (look in your .idl file).  And then add the TypeLib reference as well.  The author does not even mention this section of the registry!  

----------------------------

REGEDIT
HKEY_CLASSES_ROOT\CarServerTypeInfo.CoCar\CLSID = {22874FBC-BEE4-48e8-9EDF-8A887D488C02}
HKEY_CLASSES_ROOT\CLSID\{22874FBC-BEE4-48e8-9EDF-8A887D488C02} = CarServerTypeInfo.CoCar
HKEY_CLASSES_ROOT\CLSID\{22874FBC-BEE4-48e8-9EDF-8A887D488C02}\InprocServer32 = C:\Documents and Settings\tazochai\My Documents\Visual Studio Projects\CarServerTypeInfo\Debug\CarServerTypeInfo.dll
HKEY_CLASSES_ROOT\CLSID\{22874FBC-BEE4-48e8-9EDF-8A887D488C02}\TypeLib = {B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}
HKEY_CLASSES_ROOT\Interface\{3F2032E3-E87A-4f1f-A183-21907B0F3DCC} = IStats
HKEY_CLASSES_ROOT\Interface\{3F2032E3-E87A-4f1f-A183-21907B0F3DCC}\TypeLib = {B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}
HKEY_CLASSES_ROOT\Interface\{51514633-7B37-4671-98F1-386B39CF9E81} = IEngine
HKEY_CLASSES_ROOT\Interface\{51514633-7B37-4671-98F1-386B39CF9E81}\TypeLib = {B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}
HKEY_CLASSES_ROOT\Interface\{63C1E365-D133-4fde-8B89-351DBD153ADA} = ICreateCar
HKEY_CLASSES_ROOT\Interface\{63C1E365-D133-4fde-8B89-351DBD153ADA}\TypeLib = {B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}
HKEY_CLASSES_ROOT\TypeLib\{B59DEC8E-29CC-4b22-BB00-AF13B4348F3A} = Car Server Type Lib
HKEY_CLASSES_ROOT\TypeLib\{B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}\1.0\0\Win32 = C:\Documents and Settings\tazochai\My Documents\Visual Studio Projects\CarServerTypeInfo\Debug\CarServerTypeInfo.tlb
HKEY_CLASSES_ROOT\TypeLib\{B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}\1.0\FLAGS = 0
HKEY_CLASSES_ROOT\TypeLib\{B59DEC8E-29CC-4b22-BB00-AF13B4348F3A}\1.0\HELPDIR
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question