简体   繁体   English

将C ++代码移植到Silverlight

[英]Porting C++ code to Silverlight

I have C++ application which has UI developed using MFC, does some networking using sockets (using boost libraries) and some image processing. 我有C ++应用程序,它使用MFC开发UI,使用套接字(使用boost库)进行一些网络连接和一些图像处理。 I want to move this application into Silvelight framework (I can use 4.0 if required) so that it can be used over the internet easily. 我想将此应用程序移动到Silvelight框架中(如果需要,我可以使用4.0),以便可以轻松地在Internet上使用它。 Here I want to move all parts (UI + networking etc) in to C# but keep the image processing code in unmanaged C++ only. 在这里,我想将所有部分(UI +网络等)移动到C#中,但仅将图像处理代码保留在非托管C ++中。 I don't know .NET framework yet, but whatever I have read so far suggests that it is not possible to call the unmanaged code from a silvelight web application. 我还不知道.NET框架,但到目前为止我所阅读的内容表明,无法从一个非常简单的Web应用程序中调用非托管代码。 Is my understanding correct? 我的理解是否正确? Can something be done to achieve what I am trying to do? 可以做些什么来实现我想做的事情? Also, if somebody has some suggestions on how to go about porting the code? 另外,如果有人对如何移植代码有一些建议?

Silverlight 4 supports COM when running in trusted mode. 在受信任模式下运行时,Silverlight 4支持COM。

So, tecnically you could have Silverlight call your c++ library using COM. 因此,从技术上讲,您可以让Silverlight使用COM调用您的c ++库。

The main problem I see is on deployment and I don't think it's a good idea. 我看到的主要问题是部署,我认为这不是一个好主意。

Also, remember that Silverlight can run on Macs but COM is Windows only. 另外,请记住,Silverlight可以在Mac上运行,但COM只能在Windows上运行。

What you could do is to have the image processing happening on the server, but then you can run into scalability issues. 您可以做的是在服务器上进行图像处理,但是您可能会遇到可伸缩性问题。

Transfering large amounts of data between client and server can become an issue. 在客户端和服务器之间传输大量数据可能会成为一个问题。

UI response should probably be closely evaluated too. 也许应该仔细评估UI响应。

Regarding porting the code, well, you are most certain looking at a complete rewrite. 关于移植代码,嗯,你肯定会看到一个完整的重写。

I'd suggest using WPF instead of Silverlight if possible. 如果可能的话,我建议使用WPF而不是Silverlight。 With WPF you'd be able to reuse your C++ as is because desktop .NET / unmanaged interop is very good (P/Invoke or CLI/C++). 使用WPF,您可以按原样重用C ++,因为桌面.NET /非托管互操作非常好(P / Invoke或CLI / C ++)。

Otherwise you are stuck porting your C++ to managed code, which could prove to be laborious and the resulting code inefficient. 否则,您无法将C ++移植到托管代码,这可能会很费力并且导致代码效率低下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM