Paul Farry
Paul Farry

Reputation: 4768

Setting the COM displayed name/ProgID of an Assembly/Class for COM Clients

I'm setting up a .NET assembly that is being exposed to VB6 and the filename of the Assembly seems to be interfering with the name that VB6 uses when it creates the class.

I'm trying to find if there is a .NET attribute or setting that I can provide that will allow me to control the object instance that is created within VB6. It's purely an asthetic thing and I know that it will all just compile down, but I like things to look nice.

On my .NET assembly I have the following Attributes, note well that the ProgID seems to make no difference whatsoever to the compilation.

<
ComSourceInterfaces(GetType(IManagerEvents)),
Guid(Manager.ClassId),
ClassInterface(ClassInterfaceType.None),
ProgId("IdealposWebIt.Manager")
> _
Public Class Manager
    Implements IManager

Over in the VB6 world when referencing this class, it seems to be the Filename of the assembly gets mangled to become the part of the ProgID.

Private Sub Form_Load()
    Dim orderManager As Idealpos_WebIT_Connector.Manager
    Set orderManager = New Idealpos_WebIT_Connector.Manager

Is there anything I can do to change it? Should I just suck it up princess.

Do note that everything is creating and running correctly inside VB6, but I'd just like it to display nicely.

Upvotes: 1

Views: 901

Answers (1)

Paul Farry
Paul Farry

Reputation: 4768

After much searching, and reviewing C++ materials that without having a MIDL compiler in .NET you can't control the name that is exposed to COM.

Whatever name you use in the Assembly Name of your Project is that name that gets COMified for use in COM based applications (Early Bind). So in this case, in the project the Assembly Name is Idealpos.WebIT.Connector which then becomes Idealpos_WebIT_Connector so to make a shorter name for COM you would have to change your .NET project name which is not always something you are willing to do.

I hope this helps people in the future.

Upvotes: 1

Related Questions