Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello!

I have an application wich the last month have gotten a bug i have been unsucessfull in solving.

The application is a warehouse/production WPF application and is published to an non-internet connected LAN with around 100 Windows 7 Computers. The application is in rapid development cycle and have upto 100 update versions a year. The application also have an silent background updater which updates the app and notifies the user when finished with a restart prompt. The application is deployed to a network share wich have installtion and update folder set to the fully qualified path. However the user can chose to install the app from a Network station in his file explorer, since the same share also is mapped as this. This i have read should not be of any concern as long as the update location is set.

The bug is that we have been getting the message "The user has refused to grant required permissions to access to the application" when we perform the check for updated version. We have been trying both background and foreground update, and we also recently tried this:

C#
ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

               var appId = new ApplicationIdentity(deployment.UpdatedApplicationFullName);
               var unrestrictedPerms = new PermissionSet(PermissionState.Unrestricted);
               var appTrust = new ApplicationTrust(appId)
               {
                   DefaultGrantSet = new PolicyStatement(unrestrictedPerms),
                   IsApplicationTrustedToRun = true,
                   Persist = true
               };

               ApplicationSecurityManager.UserApplicationTrusts.Add(appTrust);


without success.


Our update code is this:
C#
 if (ApplicationDeployment.IsNetworkDeployed)
            {

                ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                var appId = new ApplicationIdentity(deployment.UpdatedApplicationFullName);
                var unrestrictedPerms = new PermissionSet(PermissionState.Unrestricted);
                var appTrust = new ApplicationTrust(appId)
                {
                    DefaultGrantSet = new PolicyStatement(unrestrictedPerms),
                    IsApplicationTrustedToRun = true,
                    Persist = true
                };

                ApplicationSecurityManager.UserApplicationTrusts.Add(appTrust);

                try
                {
                    info = deployment.CheckForDetailedUpdate();

                }
......


and it always fails with a TrustNotGrantedException and the above message. Even if i publish an update without changes to the code base.
Posted
Updated 14-Sep-16 15:33pm
v3
Comments
johannesnestler 19-Mar-15 12:15pm    
so at first it worked? after some while the updating process produced the bug? Can you "tell" from what Version it didn't work anymore?
I suspect some IT infrastructure changes or changes in your deployment code/configuration...
MrDeej 19-Mar-15 12:23pm    
About a month ago, it seems that still some computers are unaffected. I have a suspicion about a Windows Update.
But, we have an Winforms application also published on the same environment and this is working perfectly with the same update code.


Our code was unchanged and had been working for some time when it suddenly broke.

Joan Magnet 19-Mar-15 12:39pm    
We have detected a big problem with one win update this month, related to registry key's permissions, on Net Framwork (2 & 4.5) libraries.

Check this thread out mate, it explains the cause of the TrustNotGrantedException:

Clickonce app full trust update failing with TrustNotGrantedException on Windows 8[^]
 
Share this answer
 
Comments
Dave Kreskowiak 14-Sep-16 23:34pm    
After a year and a half, I seriously hope the OP isn't still looking for an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900