Showing posts with label clickonce. Show all posts
Showing posts with label clickonce. Show all posts

Tuesday, May 24, 2016

Run Program as Administrator programmatically

I need to run a program as Administrator programmatically.

Fortunately googling this was so easy. Found this one:
Run Program As Administrator in vb.net


Open the Project Properties then click on View Windows Setting button. It will open the app.manifest file.

Using Squirrel to replace ClickOnce

Installing Squirrel

While I was searching for a way to make ClickOnce deploy easier after all hardship about certificate and identity errors, I bump into Squirrel.Windows. Thanks to Travis's comment in this question: Deploy a ClickOnce application without signing. Even though no one answer that was Marked ans Answer (yet at the time), the comments really help to give me an idea about some alternatives.

I create a new project that target a .Net Framework 3.5 and start searching for it in the Manage Nuget Packages for Solution.Current latest stable version is 1.4.0. I install it right away.


Create a new Nuget Package for my Visual Studio Application

To create a new Nuget Package, I must install the Nuget Package Explorer. If uses Internet Explorer, it will run immediately to install if click the Download button.

This is when I run it:



1. I just have to create a new package (Ctrl+N).

Saturday, May 21, 2016

“An attempt was made to reference a token that does not exist” when sign the assembly

I'm working on a ClickOnce deploy-able project. Since begining of the project and many build and published, no error about this happen. but suddenly this error occur:
Cannot import the following key file: ***.pfx. The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user’s personal certificate store.

Then I try to reselect the ***.pfx in the "Project Properties->Signing->Choose a name key file". Then This message appear:
“An attempt was made to reference a token that does not exist”
I don't understand why this happen. After searching the net and many attempts for several hours, I finally able to solve it just by running the Visual Studio as Administrator.


I got it from here: Error when using Visual Studio 2010 for assembly signing: “An attempt was made to reference a token that does not exist”

But my solution was not from the chosen as answer but from Josh M.:
Running Visual Studio as Administrator fixed this issue for me.
Problem Solved.


ps: Maybe I should always run the Visual Studio as Administrator. Who knows, I might save several hours of searching.