How to get data from database in XBAP application ?

XBAP application runs with partial trust security and therefore the sandbox does not allow the XBAP application to read data from a database directly. In order to read data from the database, a web service can be used to read the data from the database in the local storage and return the dataset back to the XBAP application.

I am able to access the registry using full trust XBAP application in debug mode, when hosted in an intranet, the application crashes. What do I do?

The application crashes due to insufficient access to registry even if you have a local intranet certificate. The issue is, you get access to the registry using the CLR in debug mode, whereas when hosted in local intranet, NT security restricts you from accessing the registry, giving full access to registry in the NT security to the administrators and power users group.

How do I assign full trust to an XBAP application ?

Full trust permission can be assigned using ‘Security’ tab of the project properties. By selecting ‘This is a full trust application’ option in the security tab full trust can be assigned to the XBAP application. But be aware that it might cause security issues to your customer’s machine.

How can I use a WindowsFormsHost element to host a System.Windows.Forms ?

It can be done with the following code : [XAML] <Window x:Class='HostingWfInWpf.Window1' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:wf='clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms' Title='HostingWfInWpf' > <Grid> <WindowsFormsHost> <wf:MaskedTextBox x:Name='mtbDate' Mask='00/00/0000'/> </WindowsFormsHost> </Grid> </Window>

Where do I find System.Windows.Forms.Integration ?

The System.Windows.Forms.Integration namespace is defined in ‘WindowsFormsIntegration.dll’ which currently ships in the WinFX SDK, not in the standard redist. Therefore, the file will be found in ‘\Program Files\Reference Assemblies\Microsoft\Framework\v3.0’.