Embedding Windows Forms Applications directly in a WebBrowser

"In the past, Web developers often used ActiveX controls to provide rich client-side functionality in their Web applications. Now developers can easily build objects using the Microsoft .NET Framework that are more compact, lightweight, secure and can be hosted within Internet Explorer. By hosting .NET Windows Forms controls in Internet Explorer, developers can accomplish many client-side Web development goals..." 

This is an excellent introduction from Thiru Thangarathinam article in CodeGuru 

 In the rest of this article he provides great details on how to accomplish this task.   


Figure 1: Example of simple Hello Word Windows Forms App embedded in Browser



Figure 2: Example of a more complex Windows Forms App consuming data from a Web Service


" However before using Windows Forms controls in IE, you need to be aware of the benefits and limitations. The main benefits include: 

  •          The ability to deliver dynamic rich user experience through the Web 

  •          Automatic caching of compiled code on the client 

  •          Seamless integration with .NET Code Access Security that allows you to leverage the .NET security model from within the client side 

  •          Improved performance over Java applets 

The constraints include: 

  •           It requires Windows operating system on the client side 

  •           Internet Explorer 6.0-9.0 is the only browser that provides support for this type of hosting 

  •           It requires .NET runtime to be installed on the client machine. 

  •           It also requires Windows 2000 and IIS 5.0 or above on the server side" 

Currently my tests indicate that this technique does not apply for Windows 8. Also issues with .NET code security should be reviewed or additional configuration might be needed in order for restricted operations to be available. (This article from Dino Esposito provides more insight on these security aspects http://devcenter.infragistics.com/Articles/ArticleTemplate.Aspx?ArticleID=1264) 

IE8 No such interface

17. August 2012 10:45 by Mrojas in Javascript  //  Tags: , , , , , ,   //   Comments (0)

Well, there are several reasons why this error appears...

I had this annoying error for a few days so I decided to track it down. It seems that in my case this error was a bug in jQuery.

if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                    return a !== b && (a.contains ? a.contains(b) : true);



That code throws the exception in the a.contains(b) method call. So I tried to fix it for a while but I did not have a lot of time so I ended up patching it like:


if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                try {
                    return a !== b && (a.contains ? a.contains(b) : true);
                catch (err) {
                     return false;

In my case it works. I know is not the best solution but if you are struggling with this it might help

Output unescaped string in Razor

24. May 2012 00:03 by Mrojas in ASP.NET, HTML5, Javascript, JSON, Razor  //  Tags: , , , , ,   //   Comments (0)

While doing some experiments with Razor, and trying to generate some simple JSON objects in my ASP.NET MVC views
I had to deal with problems because my json string got a lot of weird " and other strange escape character.
That in general is very good but I needed my string just as is.

The current workaround that I have found for doing that is:
var objectInStr = @(new HtmlString(Json.Encode(Model or your object)));