views:

58

answers:

1

Background: We have a COM object written in C#. We are working with another company that has code written in VB6. We need to send them VB6 code that creates and calls objects/methods from our COM object.

I created a .tlb file from the C# COM DLL file using RegAsm.exe provided by Microsoft. I then added this .tlb file as a reference in VB6 (Project->References->Browse...). It is also checked under Available References. It is not registered as COM+.

I used this article (C#/VB6 COM Example) as a reference for all this.

Problem: The issues is that I'm referencing this COM object in my VB6 project, but none of the objects/methods/namespaces show up. There must be something simple I'm missing, but what is it? Do I need to register this as COM+, or is the problem something else?

EDIT: More info about the project
OK, so I now have access to the source code, but apparently I was mistaken. It is in C++, not C#. Our test app for the C++ COM object was in C#, but the COM object itself is C++.

Now, my new question is how do I interface with this C++ DLL. My college mentioned that it "isn't a real COM object" so is there a way to interface with it other than adding it as a reference? If not then how do I make it into a COM object?

I need to access and use functions as well as objects from this DLL.

A: 

It sounds like you don't have a proper interface for your C# class... In C# to create a proper typelib you need to create an interface for your object. Otherwise the object appears in VB6 just as you described:

I.e.

[Guid("0C3A05D1-ADF0-4d82-84BC-B59A1AEF6235")]
public interface ISomeClass
{
    [DispId(1)]
    string Foo { get; }

    [DispId(2)]
    string Bar { get; }

    [DispId(3)]
    bool Baz { get; }

}

[Guid("59EA6033-9BF3-4123-B163-9AD1F958E179"),
 ProgId("SomeModule.SomeClass"),
 ClassInterface(ClassInterfaceType.None)]
public class SomeClass : ISomeClass
{

     public string Foo 
     {
         get 
         {
             return _foo;
         }
     }
 // More implimentation
 ...

See this code project article for more details.

Kris Erickson
@Kris, added new info about the problem.
Mike Webb
Is it C++ or is it C style dll? C++ interop that isn't a proper Com DLL is going to be a serious pain in the but. Can't really help you out with what you have given, as there are many ways to interop with C++ dll's, you are going to have to supply more details and probably some of the C# test code...
Kris Erickson

related questions