views:

38

answers:

3

When objects get added to the Windows Registry, they show up like so:

MyNamespace.MyType

I seem to remember running into issues with my namespaces and classnames being too long when trying to register them for COM. Is there a maximum length limitation in registering classes in Windows or COM+?

+1  A: 

The primary way to register COM components is by their CLSID, a fixed size 16 byte number. A GUID. You can publish a ProgID, that's useful to COM clients that need to use late binding. Like scripting languages.

I have no idea if there's a length limit to ProgIDs, there isn't one defined in the COM infrastructure. Maybe the scripting language has one. I know you are using VB6, there's no need for a ProgID at all. It prefers early binding (new ClassName, not CreateObject). Which is a good idea because late bound calls are about 10,000 times slower.

Anyhoo, if you want to specify a ProgId then use the <ProgId> attribute. The normal format is AppName.ClassName, something that should rarely test any kind of length limit.

Hans Passant
@Hans I'm not sure where we found the length limit. It might have been when trying to create an ActiveX Component in VB6. Interestingly, we'll be creating a .NET component that will be both early bound in VB6 as well as late bound in a different solution that uses classic ASP/VB Script. Thanks for your answer.
Ben McCormack
ProgID's allow to use the latest version of a component, if multiple are installed. Late Binding is independent of creation through CLSID or ProgID. If performance is a concern, you can resolve it through `CLSIDFromProgID` before instantiating many objects.
peterchen
+2  A: 

Speaking of a random limit on the the "Programmatic ID"...

---------------------------
Microsoft Visual Basic
---------------------------
Programmatic ID string too long '<<project_name>>.<<control_name>>'.
The Programmatic ID must be 39 characters or less.
---------------------------
OK   Help   
---------------------------
wqw
+3  A: 
  • Have no more than 39 characters.
  • Contain no punctuation (including underscores) except one or more periods.
  • Not start with a digit.
  • Be different from the class name of any OLE 1 application, including the OLE 1 version of the same application, if there is one.*

source = MSDN

peterchen