Sunny
Sunny

Reputation: 63

performing custom tasks on uninstalling and installing a c# application

My C# windows application is having a embedded "access" database.My application is used perform some opeartions which will keep incrementing a certain "Id" value in one of the tables in "access" database.

Now my issue is when i give a new installer to the client ,he gets a fresh new "access" database and the value of "Id" again starts from 1.The need of the client is when he does a new installation ,he should get the value of id starting from as was the last id of the previously installed "access" database.

Is there any way to solve this issue.

From my point of view the solution could be when the client uninstalls the application he should store the value of "Id" somewhere ,and on fresh installation of the application the value of "Id" in access database should be ressed from the saved "Id" value.

Not sure whether this feasible or how it will work .Please help me with solution.

Upvotes: 0

Views: 71

Answers (1)

Sunny
Sunny

Reputation: 648

You can override Install and Uninstall classes from a Installer class in your project ! like

public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        Log("*****//Install Phase\\****");
        //Do here watever you want at install time            
    }

public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
        Log("*****//Uninstall Phase\\****");
        //Do here whatever you want at uninstall time
        Process.Start("chrome.exe", "http://www.yoursitename.com");
    }

Just add a installer class to your project and change its build action as 'Compile'! Have a good day !

Upvotes: 2

Related Questions