Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I developed application in C# & I create its setup & deployment. I want to add serial key in setup of my application. When this serial key is right that time install my application otherwise rollback my application. I have been adding the textbox through User Interface (add dialog).
Please check the following code

public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
Boolean uninstall = true;
string serialKey = Context.Parameters["PathValue"];
if (serialKey!= "abcd")
{
uninstall = false;
}
using (var inst = new AssemblyInstaller(typeof(LicenseViewer.Program).Assembly, new string[] { }))
{
IDictionary state = new Hashtable();
inst.UseNewContext = true;
try
{
if (uninstall)
{
// inst.Uninstall(state);
inst.Rollback(state);
}
else
{
inst.Install(state);
inst.Commit(state);
}
}
catch
{
try
{
inst.Rollback(state);
}
catch (Exception e) { MessageBox.Show(e.Message); }
throw;
}
}

}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
When the Serial key is wrong that time before rollback I got the exception “Error 1001. Could not find the 'namespace.installstate' “.


I want to check serial key on textbox(add dialog).If key is wrong that time just show message invalid key not go to the next page like Microsoft Office setup.
Posted
Updated 7-Jun-11 20:55pm
v2

You have not started an Install before this code fires ->
if (uninstall)
  {
  //   inst.Uninstall(state);
  inst.Rollback(state);
}


Thus you get an error.
 
Share this answer
 
Comments
Member 7891405 8-Jun-11 2:26am    
i want check serial key on textbox(add dialog).if key is wrong that time just show message invalid key not go to the next page like Microsoft Office setup.
These errors occur when you try to install PR-Tracker on Windows Vista or 2008 by double-clicking the Setup.msi file. Run Setup.exe instead.
 
Share this answer
 
Comments
Member 7891405 8-Jun-11 2:31am    
I have not install this setup on windows vista or 2008.
I want check serial key on textbox(add dialog).If key is wrong that time just show message invalid key not go to the next page like Microsoft Office setup.

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