0

I have several ATL COM services and would like each of them to have their own namespace, but be under a single base namespace, just like the System namespace in .NET.

For example if a C# project were to include these COM objects, all would be under the same base namespace:

using MyCompanyName.Terminator;
using MyCompanyName.Superman;
using MyCompanyName.Thor;

... instead, what I have currently is this:

using Terminator;
using Superman;
using Thor;

... which is what I do NOT want. I want to be able have a base namespace and sub-namespaces under that base. I don't know how to do this when creating an ATL service and what I need to modify to do this. Is it something I modify in the IDL file?

ykay
  • 1,877
  • 19
  • 24

1 Answers1

0

In case you are targeting managed clients it is possible to provide namespaces for them! However since COM is language independent you cannot provide namespaces using the interface description (type library). But whenever you are creating managed wrapper assemblies (that are actually referenced by the client), they can have namespaces to address the RCW objects. The keyword you are looking for is Primary Interop Assemblies. Those are assemblies that you as the vendor of the original library provide for clients to reference. To simplify this: You are doing the work, Visual Studio does for you when you are adding a reference to a COM library. You are creating the interop assembly and the customer does not reference the type library, but the assembly you generated. Using the tlbimp.exe tool it is possible to encapsulate the RCW types inside a namespace using the /namespace parameter.

Carsten
  • 11,287
  • 7
  • 39
  • 62