Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert C# dll to COM object

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
How can I convert a C# dll to a COM object, so I can use it in VBScript or JavaScript.

Thank you.
 
afaik, you cannot just convert a managed dll to COM. you need to recompile the dll as COM dll (and explicitly define which classes are COM visible). If recompilation is not possible, you can just build a wrapper and compile the wrapper as COM dll.


my 2 cents [wink]
 
Thank you.
Do you have any resources handy that I can use, I am looking on the net and so far, I have figured out the following :-
1. Recompile dll as COM -
Soln: Select the "Register for COM" in Project Properties.

How do I define which classes are COM visible?

Thank you.
 
For each class you want to expose, you need to define to basic attributes: ComVisible, and Guid.
Code:
[ComVisible(true)]
[Guid("...")] /* You provide the guid here */
public class YourClass
{
}
After you compile, a DLL and a type-lib file are generated, and your COM component gets registered automatically.

[wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top