Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some c++ .lib files(unmanaged) and I want to create a WCF service in which all the functions written in lib files can be called and finally can be used in distributed system (web, android, iphone).

Doubts:
Do I need a DCOM object to communicate cpp lib to c# and then DCOM dll is called in WCF.
Does WCF service automatic marshal from cpp to c# (using System.Runtime.InteropServies)
- I am not sure if late binding in WCF can do the magic?

Some points which I found while rnd.
I know how to create a dll from .lib file in vc++ but here problem comes to be "Intersect of cpp class functions in c# code." . Example in cpp, I had created a function getData(char* ch). Now how to call this function passing string,say; "Hello World". It gives a error as (can't overload to datatype SByte*). Tried Sbyte.Parse() and Sbyte.TryParse() but no luck.
I am sorry if it sounds confusing but any sort of help in the form of links or sample code will be highly appreciated.
Thanks,
Abhay
Posted

This article[^] by Luc Pattyn[^] explains how to use C++ libraries from C#. Further information can be found here[^] and here[^].
 
Share this answer
 
Thanks Richard for the links. But I can't use DLLImport function as I have cpp classes and want to pass objects in my functions.Therefore, Extern "c" cant be used.
 
Share this answer
 
Comments
Richard MacCutchan 14-Dec-11 8:36am    
In that case I am not sure how you would do without going through some COM interface, but my knowledge of COM is very basic.
abhay bansal 14-Dec-11 23:34pm    
Anyways, Thanks Richard.

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