Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

How do I use a C# dll in C++ COM application?

Hi, I have a C# dll that has different pulic static functions that i would like to use them in my C++ Com (unmanaged with only Win32 library) appliation.  Can someone outline the steps I need to do to use these C# function?

Thank you.
Avatar of vs1784
vs1784

You have to generate type library for that C# DLL using a command like below

tlbexp MyApp.dll /out:mytypelib.tlb

It will generate tlb file. You can use that tlb file in VC++. You can find tlbexp in .NET Framework direcotry i think.

Hope it helps

Thanks
Avatar of jkr
You can use COM interop for that purpose. See http://msdn2.microsoft.com/en-us/library/zsfww439(VS.80).aspx ("Exposing .NET Framework Components to COM")
Avatar of lapucca

ASKER

My C# dll is a library project.  Most of the functions and properties in it are public and static.  I've been using this in my C# application without creating an instance of this library class.  Is this a qualified candidate for COM interop?  The url seems to be talking about creating an instance of the library class.  Thank you.
SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial