Crossbow: Integrating Windows Forms controls in XBAP applications fails

.NET, Technical stuff, WPF
See comments
Crossbow is the technology (code name) allowing to integrate Windows Forms controls into a WPF application. Mainly, it consists of a control named WindowsFormsHost, which is part of the namespace System.Windows.Forms.Integration, and distributed in the assembly WindowsFormsIntegration.dll. This DLL can be found in Visual Studio 2005, and is also part of the WPF SDK, under Program Files\Reference Assemblies\Microsoft\Framework\v3.0 (stand June CTP, I didn't check in August CTP if it's still the same).
Integrating WinForms controls is very easy in code behind:
System.Windows.Forms.Button bnOpenColorDialog
  = new System.Windows.Forms.Button();

bnOpenColorDialog.Text = "Open WinForms color dialog";
bnOpenColorDialog.BackColor = System.Drawing.Color.Blue;
bnOpenColorDialog.ForeColor = System.Drawing.Color.White;

WindowsFormsHost oHost
  = new WindowsFormsHost();
oHost.Child = bnOpenColorDialog;

Canvas.SetTop( oHost, 80 );
Canvas.SetLeft( oHost, 8 );

this.pnMainCanvas.Children.Add( oHost );
where pnMainCanvas is a WPF Canvas located in my Page.
Unfortunately, Crossbow doesn't work when the WPF application is run as XBAP (browser hosted). A security exception is thrown (see below).
Like many other security exceptions in XBAP (sandbox), it is unclear if this is per design, or if it was by lack of resources (which means it might come in a later version of WPF).
Previous entry | Next blog entry

Responses to “Crossbow: Integrating Windows Forms controls in XBAP applications fails”

  1. Thakkar Pratik Says:

    Hi,

    I want to create appdomain in XBAP application. But it is not working though i have make it as full trusted application from security option.

    Same code is running in windows application without any error but in xbap application it is giving errror like could not load file or assemby..

    Regads
    Pratik

Comments for Crossbow: Integrating Windows Forms controls in XBAP applications fails