Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to invoke a method of a class in unmanaged dll written in C++.
e.g., DLL name: cast.dll
A class in cast.dll: parser
A function in parser class: castToObject(someVal as string)


For example here is how to access it in VB dynamically.

dim objCast
Set objCast = Server.CreateObject("cast.parser")
strCastedItem = objCast.castToObject("someValue")

I would like to access the castToObject method from C#.
Your help is highly appreciated.
Posted

If you have had googled.... Anyway i have googled for you and found below urls. Might help u

steps on calling COM dll API into my c# code[^]

COM Interop Part 1: C Sharp Client Tutorial[^]
 
Share this answer
 
Syed,

Thanks for the response. Actually, I did research and most of the search results point on using DLLImport which works perfectly if the DLL has a method to be invoked. None of them show how to invoke methods inside a class of that dll.

However, I did look at the links you've provided and as I said the first one that talks about using the DLLImport method didn't work for me because the function is in the co-clsss.

The other link could've been useful only if I know the GUID for the "parser" class inside the cast.dll. Since I don't know the GUID and also since there is no typlib for the com definition, I couldn't use the solution to solve my problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900