在WCF或C#包装器中使用c ++ .lib文件? [英] Using c++ .lib file in WCF or c# wrapper?

查看:101
本文介绍了在WCF或C#包装器中使用c ++ .lib文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些c ++ .lib文件(非托管),我想创建一个WCF服务,在其中可以调用用lib文件编写的所有功能,最后可以在分布式系统(Web,Android,iPhone)中使用.

疑问:
我是否需要一个DCOM对象以将cpp lib与c#通信,然后在WCF中调用DCOM dll?
WCF是否服务从cpp到c#的自动封送(使用System.Runtime.InteropServies)
-我不确定WCF中的后期绑定是否可以发挥作用?

我在rnd时发现的一些点.
我知道如何从vc ++中的.lib文件创建dll,但是这里的问题是"c#代码中cpp类函数的相交". .在cpp的示例中,我创建了一个函数getData(char * ch).现在如何调用该函数传递字符串,例如: 你好世界".它给出一个错误,因为(不能重载数据类型SByte *).尝试使用Sbyte.Parse()和Sbyte.TryParse(),但是没有运气.
很抱歉,如果听起来令人困惑,但是将非常感谢您提供链接或示例代码形式的任何帮助.
谢谢,
Abhay

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

推荐答案

本文 [< ^ ] www.codeproject.com/script/Membership/View.aspx?mid=648011">Luc Pattyn [此处 [此处 [ ^ ].
This article[^] by Luc Pattyn[^] explains how to use C++ libraries from C#. Further information can be found here[^] and here[^].


感谢Richard的链接.但是我不能使用DLLImport函数,因为我有cpp类,想在函数中传递对象.因此,不能使用Extern"c".
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.


这篇关于在WCF或C#包装器中使用c ++ .lib文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆