How to run WPF - XBAP as Full Trust Application - Maxim

How to run WPF - XBAP as Full Trust Application

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

 xbap project type

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

full trust app

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

app publish

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

run app from website


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

trust not granted


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

xaml code

(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):

certificate

(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"):

save certificate 01


File export wizard (step A):

save certificate 02

File export wizard (step B):

save certificate 03

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

save certificate 04

File export wizard (step D):

save certificate 05

File export wizard (step E):

save certificate 06

File export wizard (step F):

save certificate 07

(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)

ie options

Click on "Certificates" in "Content" tab:

ie options - content tab

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

ie options - certificates

File import wizard (step A):

certificate import wizard 01

File import wizard (step B):

certificate import wizard 02

File import wizard (step C):

certificate import wizard 03

File import wizard (step D):

certificate import wizard 04

Confirm importing:

certificate import wizard 05

If succeed you'll get this window:

 certificate import wizard 06

And will see certificate here:

certificate imported - ok

Do same in "Trusted Publishers" tab:

ie options - certificates - publishers

Close IE options:

 ie options - ok


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

app resign

Select registered certificate from local store:

certificate from store

(5) Republish the application:

app publish again

app publish again - msg

Now XBAP can run in "Full Trusted" mode:

xbap video player

Hope this post was helpful ;-)

 

PS: see this post about certificate extraction for XBAP applications.


Comments

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, March 12, 2008 1:19 AM by John Bailo

I am walking through the steps.

The first problem is that when I select Create Test Certificate it defaults to a .pfx key.   I deslected the Sign The Assembly checkbox, yet it keeps pulling up the _TemporaryKey.pfx and asks me to Enter password.

How can I get it to ignore .pfx and create a .cer ?

I now get a new error when trying to publish...it will not go away even if I deselect the Sign the ClickOnce manifests checkbox and/or the Sign the assembly checkbox in the Signing tab.

The error is:

"Error 1 The ClickOnce manifest for XAML Browser Applications must always be signed. You must specify properties: SignManifests (value set to True), ManifestKeyFile (with the name of your key file) and ManifestCertificateThumbprint (hexadecimal thumbprint value in SHA-1 format, of key file). Alternatively, you may use your IDE's Publish Wizard or Signing options."

I've tried using the Publish Wizard but I do not see any options that refer to Signing...

# re: How to run WPF - XBAP as Full Trust Application

Thursday, March 13, 2008 5:54 PM by John Bailo

I got it to work!   I had to rollback some other changes I made to the project.  Then I followed these instructions step by step and now I am able to run my Full Trust application over the web in a browser!

Thanks for all your help!!!!

# re: How to run WPF - XBAP as Full Trust Application

Thursday, March 13, 2008 8:08 PM by Maxim

you're welcome :)

# re: How to run WPF - XBAP as Full Trust Application

Saturday, March 15, 2008 10:23 PM by mark

How did you create the .cer file? In the steps, when he does "Copy to File" it creates a .pfx. No .cer.  So I'm confused on where that file comes from.

thanks

# re: How to run WPF - XBAP as Full Trust Application

Sunday, March 16, 2008 5:02 PM by Maxim

Mark,

as written in post from the first step:

1. go to 'project properties' -> 'signing' and check 'sign the click-once manifests'

2. click 'create test certificate' (with any desired password)

3. after the certificate was created, click on 'more details'; in opened window go to 'details' tab and click on 'copy to file', check 'no, do not export the private key', fourth step requires file saving operation (save as 'cer' file), finish wizard

4. enjoy :)

# re: How to run WPF - XBAP as Full Trust Application

Friday, March 21, 2008 1:16 AM by Dilip

This is really helpfull

# re: How to run WPF - XBAP as Full Trust Application

Thursday, April 17, 2008 4:58 PM by Subindev

Gr8........ It works for me.

Thanks a lot.....

I have been looking for a solution from last 3 months....

once again thanks....

# re: How to run WPF - XBAP as Full Trust Application

Friday, April 18, 2008 2:29 PM by Maxim

10x,

additional post about how to extract certificate from existing assembly file: blogs.microsoft.co.il/.../how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx.

# re: How to run WPF - XBAP as Full Trust Application

Monday, April 21, 2008 4:27 PM by Vadim

Hi

I'm getting the error: "The ClickOnce manifest for XAML Browser Applications must always be signed. You must specify properties: SignManifests (value set to True), ManifestKeyFile (with the name of your key file) and ManifestCertificateThumbprint (hexadecimal thumbprint value in SHA-1 format, of key file). Alternatively, you may use your IDE's Publish Wizard or Signing options." when trying to use the certificate from store. I opened the new, clean application, and keep getting this error. When using .pfx file that VS added for me, the app builds and publishes, but is not accessible from other machines in my LAN. I guess this is expected, otherwise there wouldn't have been this article. But what am I doing wrong in exporting the certificate?

Thanks in advance...

# re: How to run WPF - XBAP as Full Trust Application

Monday, April 21, 2008 11:21 PM by Maxim

Hi Vadim,

About the error: VS tells you that you have to sign the assembly ("exe" or "dll" file that produced by your project-build) and to define it under partial/full trust rules. See part "(1) Project must be signed with "Click-Once" manifest (security certificate file):" in this post about steps to sign and to define your project for "Click-Once" deployment.

About the question of "cer": Go to part with sentence "File export wizard (step B):", check "No, do not export the private key", this will allow you to generate certificate file with ext. "cer", so you'll be able to install it on client's PC.

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, April 22, 2008 1:46 PM by Vadim

Thank you, I will see what exactly I messed up there.

Anyway, I got everything to work the way it was after registering the certificate (.cer) on client machines (which I somehow didn't think of yesterday...)

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, April 23, 2008 8:42 AM by SanthanaM

I am walking through the steps.

Though I got the following error...

ERROR SUMMARY

Below is a summary of the errors, details of these errors are listed later in the log.

* An exception occurred while determining trust. Following failure messages were detected:

+ User has refused to grant required permissions to the application.

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, April 23, 2008 5:14 PM by Maxim

Probably you've missed some step or installed certificate under wrong store, see this post with detailed installation steps: blogs.microsoft.co.il/.../how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, April 23, 2008 7:46 PM by SanthanaM

thanks,

Now Its working on my system only. It shows the same error, run on some other system. Now what can I do for this.

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, April 29, 2008 9:22 PM by SanthanaM

Hello maxim,

This is run only in the system where the application is created. Its not runs in the client system.

so pls tell me the solution for this. Its very helpful to me.

Thanks

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, April 29, 2008 9:23 PM by SanthanaM.veradis

Hello maxim,

It is only run in the system where the application is developed. It's not run in the client system.

so pls tell me the solution for this. Its very helpful to me.

Thanks

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, April 29, 2008 9:50 PM by SanthanaM.veradis

Hi I do all of your instruction but i cant able to deploy, while deploying the following error shows,,

Error 2 The ClickOnce manifest for XAML Browser Applications must always be signed. You must specify properties: SignManifests (value set to True), ManifestKeyFile (with the name of your key file) and ManifestCertificateThumbprint (hexadecimal thumbprint value in SHA-1 format, of key file). Alternatively, you may use your IDE's Publish Wizard or Signing options. TrustedXbap

pls tell me how to rectify this...

# re: How to run WPF - XBAP as Full Trust Application

Monday, May 12, 2008 9:42 PM by Matt Galbraith (MSFT)

Under "File export wizard (step B):", you're telling people to distribute their private key (i.e. export this certificate with the private (signing) key) so that users can run their apps.  This opens up the possibility of malicious users signing their own applications with such a private key, resulting in fully trusted code running from a malicious source.

Always keep private keys private, and please use strong passwords on them!

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, May 20, 2008 9:00 PM by Maxim

Hi All,

I'm preparing some additional post about XBAP deployment. When I'll finish, I'll post it with all answers for common questions and fixes for snapshots/steps.

# re: How to run WPF - XBAP as Full Trust Application

Friday, June 27, 2008 3:12 PM by Rajith

Post was just informative... :)

# re: How to run WPF - XBAP as Full Trust Application

Friday, August 08, 2008 6:54 AM by Chitra

post provided exactly what i wanted ... Thank You.

# re: How to run WPF - XBAP as Full Trust Application

Monday, September 22, 2008 4:36 PM by ozzy

very cool

# re: How to run WPF - XBAP as Full Trust Application

Friday, October 10, 2008 12:36 PM by nichel

greate, thanks a lot!

# re: How to run WPF - XBAP as Full Trust Application

Thursday, November 06, 2008 12:51 PM by krish

very helpful.sent this link to my friends.

Thanks a lot..

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, December 03, 2008 9:47 AM by Saurabh

Hi,

This really helped a lot for a start. However in real time scenarios the client would not like to install the certificate in the end users machine. So how can we automate this process in XBAP ??

Thanks  

# re: How to run WPF - XBAP as Full Trust Application

Thursday, December 04, 2008 1:23 PM by Maxim

Hi Saurabh,

See comment line in blogs.microsoft.co.il/.../how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx (the comment from  subindev).

You can write some light installer application that can register certificates on client's machine, this application can be downloaded and executed by client, not a big deal, (even for dummies clients :))

# ActiveX, Silverlight, Client-side application | keyongtech

Pingback from  ActiveX, Silverlight, Client-side application | keyongtech

# re: How to run WPF - XBAP as Full Trust Application

Sunday, February 01, 2009 7:01 AM by seanmcad

This has been very helpful but I fear the last step is going to be an issue for me.

How can I manually deploy the files given that I use the Visual Studio developer version of IIS which doesnt exist until runtime so I cant deploy to it.

Thanks!

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, February 18, 2009 11:06 AM by Sebastien

Thank you very much for this post, it was very helpful. Good job.

# re: How to run WPF - XBAP as Full Trust Application

Saturday, February 21, 2009 1:46 AM by Maxim

Welcome :)

Update: Very soon I'm planning to post my last project with certificate installer.

# ManageScope, LLC

Monday, March 23, 2009 8:22 PM by ManageScope, LLC

Pingback from  ManageScope, LLC

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, March 24, 2009 8:29 AM by Star Lee

I use you method to solve my problem.

Thanks a lot!

But there is still a problem.

I can visit the WPF page after I publish it to a server becuse I install the certificate.

But I can NOT visit the WPF page via a computer which desn't install the certificate.

So, if there are any method to avoid certificate installation in the client computer? Or install the certificate automatically?

Thanks.

# re: How to run WPF - XBAP as Full Trust Application

Friday, April 10, 2009 1:40 AM by Vivien Dracon

Great Post! Star Lee: We posted on our blog how to create an automatic certinstall application. Give it a look ... www.managescope.com ... If this is a serious blog faux pas pointing someone to this, mea culpa :)

# re: How to run WPF - XBAP as Full Trust Application

Friday, April 10, 2009 7:22 PM by Maxim

Thanks :)

When I'll manage with my time, I'll wrote post about certificate installer and will refer to sources about it including www.managescope.com...

# re: How to run WPF - XBAP as Full Trust Application

Monday, April 13, 2009 8:49 AM by Star Lee

Vivien Dracon:

I read your blog.

Thanks a lot!

# re: How to run WPF - XBAP as Full Trust Application

Monday, April 27, 2009 5:51 PM by Leon Shahar

I've this page very usefull.

I'm new to running XBAP's and this realy helps. I'm having a run-time issue, after ClickOnce step related to a dual http communications bewteen the XBAP and a wcf service. The problem seems to be that once an XBAP is using the callback channel, through the "http://+80/Temporary_Listen_Addresses/some_address" I cannot launch any other instance of the XBAP. Any suggestions?

Thanks

# re: How to run WPF - XBAP as Full Trust Application

Monday, April 27, 2009 5:53 PM by Leon Shahar

Ooops.

My email address is lshahar@harris.com

Thanks

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, May 12, 2009 8:35 PM by Nigel Archer

Just wondering if someone could tell me what happens in 12 months after deploying (or creating the certificate). Will the application stop working? Will I (the developer) need to re-release the application with a new certificate and get all the users to reinstall the new certificate?

# Making an XBAP application full-trust « YouCode

Wednesday, June 24, 2009 2:35 PM by Making an XBAP application full-trust « YouCode

Pingback from  Making an XBAP application full-trust « YouCode

# re: How to run WPF - XBAP as Full Trust Application

Monday, June 29, 2009 4:40 PM by Kevin

Hello

I tried your steps. I am happy that it is working, but only in my PC.

But when i open the hosted url from networked pc then its not going to open.

I installed the certificate file on my networked pc but still the same.

So what i need to do for accessing the application from network?

Thanks

# Security issues using charts in a WPF Browser Application (XBAP)

Wednesday, July 01, 2009 7:03 PM by WPF Blog

XBAPs are deployed using ClickOnce and default to run in a sandbox, because of this you might encounter

# re: How to run WPF - XBAP as Full Trust Application

Thursday, July 30, 2009 12:56 AM by Felipe Esteves

First , that is a great article , thanks a lot =)

Im got it the same problem.

Import the certificate in "Trusted publishers" too.For me that works.

# re: How to run WPF - XBAP as Full Trust Application

Thursday, July 30, 2009 3:24 AM by gary

This is very helpful but what steps does the end user have to go through when they browse to my app?  Do they have to modify any of their browser settings?  There are quite a lot of steps there to follow, I want the end user to just be able to say yes or no.

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, August 05, 2009 10:46 PM by John G

Great Article. unfortunately it didnt work for me

I still get the error message

# re: How to run WPF - XBAP as Full Trust Application

Thursday, August 06, 2009 5:57 PM by John G

Wow.  that was incredibly annoying to get this to work. i found a post that said to add the certificate to both the TrustedRootCertificationAuthorities <strong> and</strong> TrustedPublishers

# re: How to run WPF - XBAP as Full Trust Application

Thursday, August 06, 2009 6:27 PM by John G

btw - How can be able to install the certificate automatically

# re: How to run WPF - XBAP as Full Trust Application

Friday, August 07, 2009 1:46 AM by Peter Javorsky

Hi Maxim. Thanks for this post. Unfortunately, it's not working for me. I followed all steps exatly several times with no luck. Please help.

P.S. I'm trying to write file on the local filesystem and always I get error:

System.UnauthorizedAccessException: Access to the path 'C:\date.txt' is denied.

# re: How to run WPF - XBAP as Full Trust Application

Thursday, September 10, 2009 9:02 PM by John

Great Article! I have been reading a lot of articles on how to deploy and get it working on the client side and have been pulling my hair out. Anyhow, It worked for me. Thanks for the easy tutorial on how to set it up.

I have a question for you. Can I set up the XBAP app to launch executables on the server-side when the client clicks on something?

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, September 30, 2009 7:09 PM by Luis Lopez Vega

Great Article, thank You. Questions : 1) How can I extend use of the certificate ?

2) How can I make a easy installation ?

# Fullsix Blog &raquo; Blog Archive &raquo; WPF XBAP: Import your Contacts from Outlook (demo)

Pingback from  Fullsix Blog  &raquo; Blog Archive   &raquo; WPF XBAP: Import your Contacts from Outlook (demo)

# WPF XBAP: Import your Contacts from Outlook (demo)

Tuesday, November 10, 2009 9:18 PM by Gonçalo Chaves

&#160; [PT] (for a English version, see bellow on this page, please) Olá a todos, Recentemente num projecto

# Fullsix Blog &raquo; Blog Archive &raquo; WPF XBAP: Import your Contacts from Outlook (demo)

Pingback from  Fullsix Blog  &raquo; Blog Archive   &raquo; WPF XBAP: Import your Contacts from Outlook (demo)

# re: How to run WPF - XBAP as Full Trust Application

Friday, January 08, 2010 11:06 AM by BA

I could be wrong but I think there's two things wrong with this tutorial.

1/ You say that we should choose 'Yes, export the private key' but you need to choose 'no, don't export the key' to get the .cer file.

2/ I needed to install the certificate under 'Trusted Publishers' not 'Trusted Root Certification Authorities' fot it to run on a clean client machine.

Like I say, I'm no expert but this is what I had to change to get it to work. Thanks for the info though, much easier than the way I was doing it before!

# re: How to run WPF - XBAP as Full Trust Application

Thursday, January 14, 2010 11:00 AM by Justinetz

Great Thanks, dear last poster!!! :)

It works!

# re: How to run WPF - XBAP as Full Trust Application

Saturday, January 23, 2010 11:52 AM by CarverDown

Don't stop posting such stories. I like to read articles like this. BTW add some pics :)

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, January 27, 2010 12:04 AM by Dan

I tried for days to get my XBap to not throw the Trust error. Caspol would work on occassion, but not always. This is the best article by far, and step by step instructions work great!.

One caveat though like another said. Choose "No, dont export the key" in order to see the .cer extension.

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, January 27, 2010 6:22 PM by Dan

turns out you may also have to run Caspol

# re: How to run WPF - XBAP as Full Trust Application

Thursday, January 28, 2010 6:08 AM by Dan

And on some machines the Cert appears to have no effect.  Caspol is more reliable actually.

And for that to be run the user must have admin priveledges or an admin must log on to the machine.

I hope to figure how to automate remote delivery/run of caspol.

# re: How to run WPF - XBAP as Full Trust Application

Saturday, January 30, 2010 3:01 AM by BIFF MARTIN

SURE MAKES ME MISS THE GOOD OLD DAYS WHEN WE HAD PHP, PERL, AND BASH.

HA HA!

# re: How to run WPF - XBAP as Full Trust Application

Monday, February 08, 2010 11:39 PM by Tax Attorney Atlanta

Ah, great! This cleared up some confusion I'd heard.

# re: How to run WPF - XBAP as Full Trust Application

Thursday, February 18, 2010 2:56 PM by Yaniv

Oddly, when the trusted publisher's certificate expires, Trust is not granted! How come?

# re: How to run WPF - XBAP as Full Trust Application

Sunday, March 21, 2010 2:31 AM by test

I tried HTA and it's very easy to get through

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, June 30, 2010 8:40 AM by Max

My project has some references to some third party dll. and when I publish it my localhost and run it, IIS always return me, unable to find those dlls... How come u looks never meet this issue?

# re: How to run WPF - XBAP as Full Trust Application

Friday, July 02, 2010 2:15 PM by ac

Jesus loves you

# re: How to run WPF - XBAP as Full Trust Application

Tuesday, July 06, 2010 6:38 PM by Saty

This is fine for same machine(server), but whenever accessing from another machine(client) it shows same error "Trust not Granted". Please let me know the solution for this problem.

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, July 07, 2010 12:18 AM by Pratik Desai

Install certificate on client machine as well

# re: How to run WPF - XBAP as Full Trust Application

Wednesday, July 07, 2010 12:20 AM by Pratik Desai

What if the certificate used to sing the application gets expired. I received the same error again. How to handle this in deployed application?

# Windows Azure platform for client application developers

Thursday, July 22, 2010 5:28 AM by Community Goodies

Introduction Windows Azure platform is a PaaS (Platform as a Service) offer. You can build your own SaaS

# re: How to run WPF - XBAP as Full Trust Application

Monday, August 16, 2010 12:49 PM by hotellion67

<a href=http://royalorchidholidays.se>Hotell</a> - Hotell och sådant i Thailand.

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: