Trying to register a C# DLL as a COM object
Posted on 2006-07-19
First off...much luck on the explanation that solves my problem. However, I know it is somehow possible. Anyway, I have the need to expose some C# objects to an application that works with COM objects. (QuickTest Professional to be exact). We have a lot of tests written in C#...and we want to avoid a rewrite to integrate them with Mercury. So...I have done this sample example that is very simple: Here it is:
Example (C#): Creating a Simple .NET Component
1. Create a new ClassLibrary project called TestComponent.
2. Add the following class to the project:
public class Class1
public int Sum(int num1, int num2)
return num1 + num2;
3. In the project settings set the Register for COM Interop option to True
4. Build the project.
5. By default, the component ProgID is the <Project Name>.<ClassName>.
6. In QuickTest, use this code to access the Class1 Sum method.
' Create a TestComponent.Class1 instance
Set oTestCom = CreateObject("TestComponent.Class1")
MsgBox oTestCom.Sum(5,7) 'opens a MessageBox with the number 12
I can tell you for a fact...it is far from that simple. Apparantly...my issue is with getting this DLL exposed for COM. For the love of everything good...how do I do that? My neck is hurting..my ego has been beaten into submission. HELP PLEASE! Thank you for any submissions.