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-BD 53-006097E 3F28A),
dual,
helpstring("ITheServerComO bject 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-BD 53-006097E 3F28A),
dual,
helpstring("MySink Interface"),
pointer_default(unique)
]
interface IMySinkID : IDispatch
{
};
[
uuid(FA22E138-9D0A-11D3-BD 53-006097E 3F28A),
version(1.0),
helpstring("TheServer 1.0 Type Library")
]
library THESERVERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(FA22E146-9D0A-11D3-BD 53-006097E 3F28A),
helpstring("_ITheServerCom ObjectEven ts Interface")
]
dispinterface _ITheServerComObjectEvents
{
properties:
methods:
};
[
uuid(FA22E145-9D0A-11D3-BD 53-006097E 3F28A),
helpstring("TheServerComOb ject Class")
]
coclass TheServerComObject
{
[default] interface ITheServerComObject;
[default, source] interface IMySinkID;//Error
[default, source] dispinterface _ITheServerComObjectEvents ;
};
};
Please help me.
Your sincerely
andla
error MIDL2233 : too many default interfaces specified for coclass : _ITheServerComObjectEvents
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-BD
dual,
helpstring("ITheServerComO
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-BD
dual,
helpstring("MySink Interface"),
pointer_default(unique)
]
interface IMySinkID : IDispatch
{
};
[
uuid(FA22E138-9D0A-11D3-BD
version(1.0),
helpstring("TheServer 1.0 Type Library")
]
library THESERVERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(FA22E146-9D0A-11D3-BD
helpstring("_ITheServerCom
]
dispinterface _ITheServerComObjectEvents
{
properties:
methods:
};
[
uuid(FA22E145-9D0A-11D3-BD
helpstring("TheServerComOb
]
coclass TheServerComObject
{
[default] interface ITheServerComObject;
[default, source] interface IMySinkID;//Error
[default, source] dispinterface _ITheServerComObjectEvents
};
};
Please help me.
Your sincerely
andla
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
The program compiles. :-)
Thanks!
Thanks!
ASKER