views:

42

answers:

2

I have an ATL C++ in-proc COM component. This component is not for external use - I only need it for use in our application.

Once in a while users put it into COM+ and this leads to all sorts of weird errors - "Access denied", etc which I'd like to just never hear about. The best way would be to do something that would prohibit putting the component into COM+ so that it can only be used as an in-proc server. Is there a way to do this?

+1  A: 

Do you implement only your own interfaces? If so, you should be able to mark them "[local]" in the IDL, and then strip the module of all marshalling information (type library, P/S), etc.

If there's no basis for marshalling available, COM+ shouldn't be able to register the module. COM+'s mechanism for interception relies on forcing objects into a remote context and getting in between the proxy and stub and their corresponding parties. So, if you remove every opportunity for marshalling, it shouldn't be able to intercept your interface methods.

Kim Gräsman
I checked all the things you suggest but still COM+ is happy to add the component. I guess it will be unusable - CoCreateInstance() will fail with different complains like "interface not supported" - but this is in fact the same problem I started with. So instead of fixing the problem I narrowed the surface it could come from. Usually users add our component because its ProgID is in the list of registered components and is similar to ProgIDs of our other components. So they just "add everything". I changed the registry exposure code so that it only exposes the ClassId...
sharptooth
...and hope the problem will never bother us again. Thanks a lot for suggestions anyway - now we know that these steps don't really solve the problem.
sharptooth
Thanks for the follow-up info!
Kim Gräsman
+1  A: 

Prevent registering your module is finalized and then use your DLL as described in this article Creating COM objects directly from the dll.

lsalamon
Great idea. Especially since I always redistribute the COM component and it is always in the same folder as its consumer.
sharptooth

related questions