yoavo
asked on
ATL: ATL events question
Hi,
I have a COM VC++ server which fires events and a VC++ client which catching the event using an ATL sink (IDispEventImpl). I have a SINK_MAP in the client, and the events are recieved OK.
My question is:
In the client I'm using #import to the .tlb/.dll of the server. If I do not use "named_guids" attribute, then I do
not get the events. Are the "named_guids" is a must attribute to recieve events ???
If it is a must then I have a second problem:
My server contains several Dll's, and inorder to make the client simpler I use the "rename_namespace" attribute to one common name:
#import "MyDll1.tlb" rename_namespace ("MyProj")
#import "MyDll2.tlb" rename_namespace ("MyProj")
#import "MyDll3.tlb" rename_namespace ("MyProj")
Now, when trying to add the "named_guids" attribute to each one of the "import" lines, I fail in compilation:
"'LIBID_MyProj' : redefinition; multiple initialization... "
Can someone please advise ???
thanks,
Yoav.
I have a COM VC++ server which fires events and a VC++ client which catching the event using an ATL sink (IDispEventImpl). I have a SINK_MAP in the client, and the events are recieved OK.
My question is:
In the client I'm using #import to the .tlb/.dll of the server. If I do not use "named_guids" attribute, then I do
not get the events. Are the "named_guids" is a must attribute to recieve events ???
If it is a must then I have a second problem:
My server contains several Dll's, and inorder to make the client simpler I use the "rename_namespace" attribute to one common name:
#import "MyDll1.tlb" rename_namespace ("MyProj")
#import "MyDll2.tlb" rename_namespace ("MyProj")
#import "MyDll3.tlb" rename_namespace ("MyProj")
Now, when trying to add the "named_guids" attribute to each one of the "import" lines, I fail in compilation:
"'LIBID_MyProj' : redefinition; multiple initialization... "
Can someone please advise ???
thanks,
Yoav.
ASKER
This will probably work, but as I mentioned before I want all the Dll's to be renamed to one name.
Your problem is the precise reason why libraries have their own namespaces in the first place.
[un]Fortunately, there is a solution to your problem.
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB ID_MyProj1 ") named_guids
#import "MyDll2.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB ID_MyProj2 ") named_guids
#import "MyDll3.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB ID_MyProj3 ") named_guids
[un]Fortunately, there is a solution to your problem.
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB
#import "MyDll2.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB
#import "MyDll3.tlb" rename_namespace ("MyProj") rename("LIBID_MyProj","LIB
ASKER
I tried it but it doesn't work. I still get the compile error message.
With the exact same error ??
"'LIBID_MyProj' : redefinition; multiple initialization... "
"'LIBID_MyProj' : redefinition; multiple initialization... "
ASKER
Yes.
Try excluding the LIBIDs, as they're generally never referenced anyway.
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
#import "MyDll2.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
#import "MyDll3.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
#import "MyDll2.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
#import "MyDll3.tlb" rename_namespace ("MyProj") exclude("LIBID_MyProj") named_guids
ASKER
I still get the same error...
Just noticed an error in my orignal post. Sorry.
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj Lib1") named_guids
#import "MyDll2.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj Lib2") named_guids
#import "MyDll3.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj Lib3") named_guids
The LIBID don't even exist yet, so you can't rename them. It should be the name of the library itself.
In your original IDL, you should have:
[
uuid(...),
version(x.x),
helpstring("blah Type Library")
]
library MyProjLib //*** this is the name you want to specify for rename
{
...
}
[this post may be wrapped - if so unwrap it!!]
#import "MyDll1.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj
#import "MyDll2.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj
#import "MyDll3.tlb" rename_namespace ("MyProj") rename("MyProjLib","MyProj
The LIBID don't even exist yet, so you can't rename them. It should be the name of the library itself.
In your original IDL, you should have:
[
uuid(...),
version(x.x),
helpstring("blah Type Library")
]
library MyProjLib //*** this is the name you want to specify for rename
{
...
}
ASKER
"MyProjLib" is not written in any idl !!!
"MyProj" is just a name that the client renamed for easy access to the tlb's of the client.
"MyProj" is just a name that the client renamed for easy access to the tlb's of the client.
Yes, but those original tlb files must have been generated from source. It's that source that you need to view, to ascertain what name it is you're wanting to rename in the first place.
It is likely to be the original namespace name.
It is likely to be the original namespace name.
ASKER
I tried it. still I get the same error...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not that expert in COM programming, but I have a suggestion. Try to put the imports in the client code like this:
#import "MyDll1.tlb" rename_namespace ("MyProj1")
#import "MyDll2.tlb" rename_namespace ("MyProj2")
#import "MyDll3.tlb" rename_namespace ("MyProj3")
Then put:
using namespace MyProj1;
using namespace MyProj2;
using namespace MyProj3;
Then add the "named_guids" attribute and try to compile.
Thanks,
Khalid Omar.