从WPF应用程序远程访问C ++ DLL [英] Remote access to C++ DLL from WPF application

查看:102
本文介绍了从WPF应用程序远程访问C ++ DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,请帮我解决一些问题!我有一个用c ++写的dll,想要使用位于另一台计算机上的wpf应用程序的函数。是否可以这样做?



我尝试过:



我曾尝试使用RPC,但它只适用于两个c ++应用程序。

另外我听说WCF只用于两个.NET应用程序,不是吗?

Hello, please help me with some problem! I have a dll written on c++ and want to use its functions from wpf application that is located on another computer. Is it possible to do it?

What I have tried:

I've tried to use RPC, but it works only with two c++ applications.
Also I heard that WCF is used only with two .NET apllications, isn't it?

推荐答案

您可以使用两个 .NET 应用程序,一个是本地计算机(比如 client )ant另一个在远程的(比如服务器)。网络通信发生在客户端服务器之间,因此您可以使用 WCF (或其他)。服务器与 C ++ DLL 接口(例如,使用 P / Invoke )。

另一种选择是将 C ++ DLL 转换为 DCOM 服务器。
You could use two .NET applications, one othe the local machine (say client) ant the other on the remote one (say server). The network communication happens between client and server so that you may use WCF (or whatever). The server interfaces with the C++ DLL (using, for instance P/Invoke).
Another option would be transforming the C++ DLL into a DCOM server.


我可能是WCF并使用.NET制作服务器。从.NET,您可以使用混合模式C ++ / CLI或使用P / Invoke来使用C​​ ++代码。如果你有comp'ex C ++代码,混合模式会更容易。如果你有像Windows API一样的免费功能,P / Invoke是合适的。



另一方面,如果你的通信已经在客户端和服务器之间工作,你可能会更喜欢使用WPF应用程序中的C ++ / CLI。



所以有一些可能性,但最好的可能取决于你现有的代码......
I would probably ise WCF and make the server using .NET. From .NET, you can use your C++ code either by using mixed-mode C++/CLI or by using P/Invoke. Mixed-mode would be easier if you have comp'ex C++ code. P/Invoke would be appropriate if you have free functions much like Windows API.

On the other hand, if you communication already works between the client and server, you might prefer to use C++/CLI from your WPF application.

So there are a few possibilities but the best one depends on you existing code...


这篇关于从WPF应用程序远程访问C ++ DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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