Program | Control here on the specific implementation of the assembly version of the control simply say two ways. Hope to have a certain reference meaning it.
1. Manual Encoding Implementation:
Adding a static, read-only String Type property in a class codeversion represents the version number of the assembly (that is, the class in which the variable is). For example, the member class was written for the first time on January 20, 2005, followed by the upper part of this article (http://blog.csdn.net/crazytomato/archive/2005/01/28/ Codelibraryversioncontrolshang.aspx), the assembly's compiled version number should be 1.0.2005-01-20.0, and the code is as follows:
Class Member
{
public static string Codeversion
{
Get
{
return "1.0.2005-01-20.0";
}
}
Other Code ...
}
When you use an assembly in your page code, you determine the assembly version before initializing the class or using a static method of the class. Use the required requirements for the version symbol. For example:
... Other Code ...
If (member.codeversion = = "1.0.2005-01-20.0")
{
Member ' = new Member ();
Other Code ...
}
Else
{
throw new Exception ("The version of the assembly being used is not the version you need!") ”);
}
Or do some processing of the version number string first:
... Other Code ...
string memberversion = Member.codeversion;
String majormemberversion = Memberversion. Substring (0, 1);
int intmajormemberversion = Convert.ToInt32 (majormemberversion);
If (intmajormemberversion >= 2)
{
Member ' = new Member ();
Other Code ...
}
Else
{
throw new Exception ("The version of the assembly you are using is old, use a newer version of the assembly!") ”);
}
2. To use a strong name for an assembly:
The general description is listed here only
First, the key file is generated using the Strong Name tool (Sn.exe);
Then, you add relevant information to the Assembly's properties and write the version number, area, and so on, for example:
[Assembly:assemblyversion ("1.0.2005-01-20.0")]//assembly version number
[Assembly:assemblykeyfile ("Keyfile.snk")]//Key file generated by Sn.exe
Then the strong name is used for the assembly after compilation, and the version number is given 1.0.2005-01-20.0
You can then use this assembly when you use it. NET provides methods to access the property values of the assembly;
You need to bind only the version number you need when you use the assembly, or use the desired version policy to achieve versioning and no longer need to manually check and match version information.
For details, the MSDN and. Net Framework SDK documentation can be consulted with the strong Name tool, the binding version number, and the version policy.