简体   繁体   中英

Communication between .net winform and webform

I need to make a webform communicate with a winform and back to the webform. The reason for this is it exists a webform software already made, and now it's needed the behavior of a .net component only available for winforms. We've tried going with Process.Start and shell.execute but with this approach the software hangs or it takes too long to respond. The webform also needs to be called from client pcs in the network, I think this adds another problem due to the non possibility of calling the execution of a file from a webform remotelly, but I dont know much about this technical issue

we've read some articles about embedding a winform in a webform, sending data from a winform to a webform, etc. and we would like to know what's the recommend approach (if there is any) for handdling a situation like this.

If you have access to the source code for the WinForms application, then your best approach is to extract the code that you need from there and incorporate it directly into your WebForms application.

If this code needs to be used by both the WinForms and your WebForms application, then you should instead refactor the code that will be shared by both into a separate class library (DLL), which is then used by both applications.

If you only have the EXE of the windows application, and it is a .Net application, you can use Reflection to create and use objects defined there.

If it's not a .Net EXE, goodbye and thanks for all the fish (unless it's COM, in which case goodbye and thanks for all the fish).

Update: I have never tried this, and I do not recommend it, but I'm assuming that you basically want to be able to use a windows-forms based visual component in a web application (ie you want this thing to show up in their browser).

You may be able to rebuild each Form in the original WinForms project as an ActiveX control that is then situated on a web page. This link describes how to create a basic ActiveX control in .Net:

http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx

I have no idea about browser support for ActiveX controls these days (I know there's some still), and this approach would certainly not work on non-Windows OSes. Also, you have to deal with deploying and installing the visual component on each client machine (and you'd need to check your licensing agreement for this control - it almost certainly will specifically prohibit this type of use).

In theory, though, this would work. An ActiveX control can more or less do or use anything that a regular Form can (subject to permissions etc.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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