Some VB6 and Windows Forms applications are still great but probably you need them to reach a bigger audience.
There are now amazing devices with internet access, but all of then different in hardware and software combinations.
HTML and in particular HTML5 five technologies provide an unifying set of technologies that are supported by the main industry vendors. HTML5 browsers are available on tables, cell phones, linux/mac/windows PCs.
In this post I will add references to other pages which do a great work on explaining how to use this approach to host a Windows Forms App inside a WebBrowser.
The technique described here is a deployment solution to ease distribution of applications modernized from legacy technologies to Windows Forms, maybe using the Artinsoft\Mobilize.NET tools ;)
NOTE: "This workaround of .NET Winforms to WPF and then hosting it in a browser isn't truly moving a Windows based application to a web based application. e.g. database calls will be made from inside the browser on the users PC to the database, not via the IIS server. Therefore this functionality is most useful if you have connected your Winforms UI to you back-end code using web services, then you can have a somewhat web based application."
Adam Berent gives step by step instrutions:
Figure 1: Example of Windows Forms applications running inside FireFox browser using an XBAP wrapper.
Some details that are missing in this article are related to how to publish the application on IIS, and these can described as:
1. Create a test Certificate within Visual Studio and sign it against the project.
The following links provides information on how to sing the xbap with your own certificate.
2. Within VS publish the application.
4. Install the certificate on the Client PCs
The certificate must be added in the trusted publisher and in the trusted root authority. If this is not done correctly you get the error 'Trust not granted'
In this post I will add references to other pages which do a great work on explaining how to use this approach to host a Windows Forms App inside a WebBrowser.
The technique described here is a deployment solution to ease distribution of applications modernized from legacy technologies to Windows Forms, maybe using the Artinsoft\Mobilize.NET tools ;)
NOTE: "This workaround of .NET Winforms to WPF and then hosting it in a browser isn't truly moving a Windows based application to a web based application. e.g. database calls will be made from inside the browser on the users PC to the database, not via the IIS server. Therefore this functionality is most useful if you have connected your Winforms UI to you back-end code using web services, then you can have a somewhat web based application."
Adam Berent gives step by step instrutions:
Figure 1: Example of Windows Forms applications running inside FireFox browser using an XBAP wrapper.
Some details that are missing in this article are related to how to publish the application on IIS, and these can described as:
1. Create a test Certificate within Visual Studio and sign it against the project.
The following links provides information on how to sing the xbap with your own certificate.
2. Within VS publish the application.
4. Install the certificate on the Client PCs
The certificate must be added in the trusted publisher and in the trusted root authority. If this is not done correctly you get the error 'Trust not granted'
Recently I had to deal with targeting an XBAP application that had some Windows Forms controls.
The problem is that those controls can only be used in a trusted environment. If you try to debug an XBAP with some Windows Forms Controls you will get an exception like:
Message: Cannot create instance of 'Page1' defined in assembly 'XBAPWithWinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Page1.xaml' Line 1 Position 7.
It took me a while to found a solution, and it was thru Scott Landford Blog that I found a way around.
In short what he recommends to do is:
Change your settings to:
Start Action->Start external program = %windir%system32\PresentationHost.exe
In my case (and the case of most people that is: c:\windows\system32\PresentationHost.exe)
Start Options->Command line arguments = -debug "c:\projects\myproject\bin\debug\MyProject.xbap" -debugSecurityZoneUrl "http://localhost:2022"
Copy the value from the Start URL after the –debug argument
Very import for using WinForms components you must run in FULL TRUST
Here is some XBAP code using a WinForms WebBrowser. They designer does not like it a lot but it works:
XBAPWithWinforms.zip