Introduction
This simple code checks for updates. The solution contains a window application and a class library. The main functionality lies in the class library while the window application contains user interface logic. You can tell the user that a new update is available for download etc.
Using the Code
In your class library project, for example, you have a method getName()
that returns the name of the user in lower case.
public function string getName(string name)
{
return name.ToLower();
}
Later on, it changed from name.ToUpper()
in your class library, but the end user has the old code. So the following code in your window application checks for updates:
private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
{
TestAssembly.Class1 myClass = new TestAssembly.Class1();
Type type = myClass.GetType();
Assembly assembly = Assembly.GetAssembly(type);
MessageBox.Show(assembly.GetName().Version.ToString() + " " +
assembly.GetName());
Assembly objAssembly = null;
objAssembly = Assembly.LoadFrom("http://www/homes/adeel/TestAssembly.dll");
MessageBox.Show(objAssembly.GetName().Version.ToString()+ " "+
objAssembly.GetName());
if (objAssembly.GetName().Version.Major > assembly.GetName().Version.Major)
{
MessageBox.Show("An update is available.");
}
else if (objAssembly.GetName().Version.Major <
assembly.GetName().Version.Major)
{
MessageBox.Show("You have the latest version.");
}
}
History
- 9th January, 2008: Initial post
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.