InPlaceHostingManager: Why Does AssertApplicationRequirements() Throw a TrustNotGrantedException?


As you may remember, InPlaceHostingManager is a part of the ClickOnce API that enables a .NET application to download and install other ClickOnce applications. It’s pretty straightforward to use – but there may be one area that trips you up.

I was chatting in email with an MVP about why his InPlaceHostingManager application was throwing a TrustNotGrantedException from AssertApplicationRequirements(). As it turns out, he had missed one of the requirements for using InPlaceHostingManager: all applications you install must be signed using a certificate that is installed on the local machine as a trusted publisher.

This requirement is discussed in the main doc page for InPlaceHostingManager. However, I currently do not doc this exception as being generated by AssertApplicationRequirements(). So it’s no wonder that people aren’t picking up on this. This doc error will be fixed in the next doc build. Until then, consider yourself advised.

For more about trusted publishers, check out Brian Noyes’ excellent article on the subject. (Yes, his article is better than my docs. I’ll be correcting this soon.)

Comments (1)

  1. Fhali says:

    This is a great post, I’ve been working quite a bit with InPlaceHostingManager.  I had noticed ApplicationTrustManager, which is able to display a dialog box exactly like how Internet Explorer is able to.  The problem I always have is that even if I click the "Install" button on my custom application, it still gets an exception, stating that the user doesn’t trust the application.  IE is able to install the application no problem.  Also, if the application is already installed via IE, then my application is able to run the application no problem (well, by using magic code which runs the application by using Activator to create an instance of the application via it’s ActivationContext).

    Basically, IE can install the program, my app can’t.  IE can run the installed program, my app too can run the already installed program.  Also, when adding a custom IApplicationTrustManager, both IE and my app, when installing the application, gets a wierd exception when attempting to run the application.