How to run WPF - XBAP as Full Trust Application

XBAP
What is XBAP

XBAP (XAML Browser Application) is a new Windows technology used for creating Rich Internet Applications.

While windows applications are normally compiled to an .exe file, browser applications are compiled to an extension .xbap and can be run inside Internet Explorer.

Xbap applications are run within a security sandbox to prevent untrusted applications from controlling local system resources. (e.g  deleting local files)

 

Recently I work on WPF-XBAP application that will run from intranet website:

 

This application must have unrestricted access to client's OS resources (that is unusual for XBAP projects):

How to run WPF - XBAP as Full Trust Application_第1张图片

I publish it on local website by using "Click-Once" deployment mechanism:

User can launch the application from deployment page (also can run application setup):


I get security error ("User has refused to grant required permissions to the application"):


Means that application tried to perform some restricted action, beyond of XBAP sandbox. Actually it tried to read local video file:

How to run WPF - XBAP as Full Trust Application_第2张图片

(It reads video file from local source, for preview option before uploading it to FTP server)

After some research I found how to fix that:


(1) Project must be signed with "Click-Once" manifest (security certificate file):

How to run WPF - XBAP as Full Trust Application_第3张图片

(If project doesn't contain "Test Certificate" click on rounded button to create a new one)

(2) After temporary certificate was created we'll save it into file (click on "More Details"):


File export wizard (step A):

File export wizard (step B):

How to run WPF - XBAP as Full Trust Application_第4张图片

File export wizard (step C):
(Enter username and password, only if you did so while "Test Certificate" creation in par. 1)

How to run WPF - XBAP as Full Trust Application_第5张图片

File export wizard (step D):

File export wizard (step E):

How to run WPF - XBAP as Full Trust Application_第6张图片

File export wizard (step F):

(Now project certificate is saved as external file)

(3) Now we'll go to Internet Explorer and will register this certificate:
(Open "Internet Options" from "Tools" menu)

Click on "Certificates" in "Content" tab:

How to run WPF - XBAP as Full Trust Application_第7张图片

Import certificate file from "Trusted Root Certification Authorities" tab:

How to run WPF - XBAP as Full Trust Application_第8张图片

File import wizard (step A):

How to run WPF - XBAP as Full Trust Application_第9张图片

File import wizard (step B):

How to run WPF - XBAP as Full Trust Application_第10张图片

File import wizard (step C):

How to run WPF - XBAP as Full Trust Application_第11张图片

File import wizard (step D):

How to run WPF - XBAP as Full Trust Application_第12张图片

Confirm importing:

How to run WPF - XBAP as Full Trust Application_第13张图片

If succeed you'll get this window:

 

And will see certificate here:

How to run WPF - XBAP as Full Trust Application_第14张图片

Do same in "Trusted Publishers" tab:

How to run WPF - XBAP as Full Trust Application_第15张图片

Close IE options:

 


(6) No we'll go to "Signing" tab in project options and will select registered certificate:

How to run WPF - XBAP as Full Trust Application_第16张图片

Select registered certificate from local store:

(5) Republish the application:

How to run WPF - XBAP as Full Trust Application_第17张图片

How to run WPF - XBAP as Full Trust Application_第18张图片

Now XBAP can run in "Full Trusted" mode:

How to run WPF - XBAP as Full Trust Application_第19张图片

Hope this post was helpful ;-)

 

 

How to run WPF-XBAP Application in Full-Trust Mode (Post #2: certificate extraction)

In previous post I wrote about running WPF-XBAP application on client machine in "Full-Trust Mode".

How to run WPF - XBAP as Full Trust Application_第20张图片

That worked fine and the post was helpful (I know this from post's talk-backs).

I described how to generate security certificate and how to install it on client machine (thru IE options).

How to run WPF - XBAP as Full Trust Application_第21张图片

Recently, I worked with XBAP deployment files and required to copy them to new IIS server, during the process I've forgotten to include certificate (ext: "cer") file. I tried to open the application from client machine (in IE or Firefox) and got error message, that tells about security restrictions and that client has refused XBAP application in full-trust mode.

How to run WPF - XBAP as Full Trust Application_第22张图片

clip_image008

I know another way to generate certificate file without using MS Visual Studio and I'll show it here.

Some Introduction…

What are "deployment files"? – XBAP application BUILD generates assemblies and other resources that required running XBAP application. These files can be placed on IIS virtual folder and being downloaded to remote client machine by using supported Internet browser (IE or Firefox).

To see which files will be included in deployment folder go to "Publish" tab in project settings form and click on "Application Files":

To see options for deployment and how the setup page will look go to "Publish" tab in project settings form and click on "Options":

How to run WPF - XBAP as Full Trust Application_第23张图片

Check option: "Use '.deploy' file extension". - This is helpful for full-trust mode (some machines don't allow downloading assembly files like EXE and DLL):

How to run WPF - XBAP as Full Trust Application_第24张图片

If you want to include some additional files for application deployment, go to "Publish" tab in project settings form and click on "Prerequisites":

clip_image015

"Prerequisites" - setup-package files like .Net 2.*-3.* or Windows-Installer 3.*:

To generate deployment files and to publish them in selected folder click "Publish Now" in "Publish" tab in project settings form and click on "Prerequisites":

How to run WPF - XBAP as Full Trust Application_第25张图片

"Publish Now" generates these files:

"index.htm" is a deployment page, which was build with two options to run XBAP (Click-Once) application. "Run" option opens setup dialog (in case that application runs at first time or deployed with as new version), "launch" opens XBAP directly (without the installation process):

How to run WPF - XBAP as Full Trust Application_第26张图片

Usually I copy certificate file into this directory and place a link for download on "index.htm", but what can I do if I've forgotten to create the certificate file and already copied deployment files to client's IIS server and I don't have MS Visual Studio to create the new one from sources or event don’t have any sources (project code source files)? Answer: I can extract certificate into file from deployment executables. I can extract it from "setup.exe" file or from original "EXE" or "DLL" file if it wasn’t converted into other unknown file type.

I'll show ho to extract certificate from "setup.exe" (this file includes the same certificate as XBAP-Application EXE files).

1. Go to deployment folder and do right-click on "setup.exe" file:

How to run WPF - XBAP as Full Trust Application_第27张图片

2. Open "Properties" form and go to "Digital Signatures" tab page, select included digital signature and click on "Details":

3. Click "View Certificate" in "General" tab page:

How to run WPF - XBAP as Full Trust Application_第28张图片

4. Click on "Copy to File" in "Details" tab page:

5. Proceed with opened "Certificate Export Wizard":

(5.1)

How to run WPF - XBAP as Full Trust Application_第29张图片

(5.2)

How to run WPF - XBAP as Full Trust Application_第30张图片

(5.3) you can place extracted "cer" file in deployment folder for future use:

How to run WPF - XBAP as Full Trust Application_第31张图片

(5.4)

How to run WPF - XBAP as Full Trust Application_第32张图片

When you'll finish with wizard you'll get "cer" file:

How to run WPF - XBAP as Full Trust Application_第33张图片

See previous post with instructions that will help you with certificate installation. I found this post that also describes how to run XBAP in Full-Trust mode.

 

From: http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx

你可能感兴趣的:(File,application,internet,WPF,Deployment,wizard)