Link to home
Start Free TrialLog in
Avatar of andla
andla

asked on

Problem with the coclass in the .idl file

I don't understand i follow the instructions and now this.


error MIDL2233 : too many default interfaces specified for coclass : _ITheServerComObjectEvents [ Coclass 'TheServerComObject'  ]


From the samplecode in:
http://msdn.microsoft.com/workshop/components/activex/part3.asp



When i tried to do the following:
"
You also need to add information to  CTheServerComObject's coclass  declaration at the bottom of the library definition, as follows:
[default, source] interface IMySinkID;
Take a look at the IDL shipped with the sample to see exactly where it should be placed, if necessary.
"









My idl file looks like this:

// TheServer.idl : IDL source for TheServer.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (TheServer.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

      [
            object,
            uuid(FA22E144-9D0A-11D3-BD53-006097E3F28A),
            dual,
            helpstring("ITheServerComObject Interface"),
            pointer_default(unique)
      ]
      interface ITheServerComObject : IDispatch
      {
        //import "oaidl.idl";
            HRESULT HelloWorld();
            HRESULT AcceptNewValue([in]long lNewValue,
                       [out, retval] long* lpFormerValue);
      };


//sink interface
[
 object,
 //use guidgen to generate a unique id
 uuid(C02E5360-9DD6-11d3-BD53-006097E3F28A),
 dual,
 helpstring("MySink Interface"),
 pointer_default(unique)
]
interface IMySinkID : IDispatch
{
};









[
      uuid(FA22E138-9D0A-11D3-BD53-006097E3F28A),
      version(1.0),
      helpstring("TheServer 1.0 Type Library")
]

library THESERVERLib
{
      importlib("stdole32.tlb");
      importlib("stdole2.tlb");

      [
            uuid(FA22E146-9D0A-11D3-BD53-006097E3F28A),
            helpstring("_ITheServerComObjectEvents Interface")
      ]
      dispinterface _ITheServerComObjectEvents
      {
            properties:
            methods:
      };

      [
            uuid(FA22E145-9D0A-11D3-BD53-006097E3F28A),
            helpstring("TheServerComObject Class")
      ]


      coclass TheServerComObject
      {
            
            [default] interface ITheServerComObject;
            [default, source] interface IMySinkID;//Error
            [default, source] dispinterface _ITheServerComObjectEvents;
            
      };

};




Please help me.

Your sincerely
andla
Avatar of andla
andla

ASKER

I cant rind the sourcefiles anywhere.
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andla

ASKER

Witch one must i remove? If i remove the wrong one then changes will probebly destroy the whole project. I wish i could find the sourcefiles for the sample project.
Just remove the default attribute. You can still keep the interface.

The default attribute Indicates that the interface or dispinterface, defined within a coclass, represents the default programmability interface. This attribute is intended for use by macro languages.
Avatar of andla

ASKER

The program compiles. :-)

Thanks!