Saturday, March 31, 2007

How To Create A Full Trust XBAP Application In WPF.

I recently faced some problem while creating XBAP application in WPF like trying to develop application which is contain IO file accessing from the browser application. As you may know, WPF Web Browser applications run in a sandbox, which allows them to be installed without any security prompts. However, there are cases, such as intranet applications, where allows an in-browser application to do more makes sense. which I thought I'd share to this with you people.

The Following Steps helps to produce Full trust XBAP Application.

Step 1:

Change the TargetZone of the appliction to custom. This can be done manually by hacking the .proj file or can be done in Visual Studio by going to Project Properties, going to the Security tab, and changing the dropdown to (custom).

Step 2:

Add the Unrestricted="true" attribute to the manifest of the appliction, which is located in the Properties folder. The manifest should look something like this.

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true"/>
</applicationRequestMinimum>
</security>
</trustInfo>
</asmv1:assembly>


Step 3:

Deploy the application using the Visual Studio Publish Wizard.

Step 4:

If you want to deploy this from the web, the certificate used to sign the manifest will have to be added to the Trusted Publishers store within Internet Explorer. By default, VS generates a .pfx key when you create a Web Browser application. Of course, real deployments, a company issued certificate would be more appropriate to use. Getting a cert into the store can be done by double clicking the cert or by using the certmgr tool with the appropriate commandline switches.

For some more Idea You may try with this ...
http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_fxdeploy/html/b24a1702-8fbe-45b1-87a0-9618a0708f1d.asp?frame=true

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/ServerHelp/2c03582f-00b2-43e5-ae1d-493894ad0fd7.mspx

Enjoy !!!!! If You couldn't get ,please leave the comment about what you want exactly and what type of exception you are getting. It will try to give solution for your problem ..