22

I have written a DLL in C# using VS2005.

Currently the DLL is showing a version number of 1.0.0.0.

How do I set this version number to something different?

Craig Johnston
  • 5,303
  • 8
  • 27
  • 30

6 Answers6

29

look in the AssemblyInfo.cs file for the following line, and set it to whatever version number you want:

[assembly: AssemblyVersion("1.0.0.0")]
Mark Heath
  • 48,273
  • 29
  • 137
  • 194
11

You can either specify the file version using the AssemblyFileVersionAttribute directly...

Instructs a compiler to use a specific version number for the Win32 file version resource.

...or you can remove this attribute entirely which will mean that the file version defaults to the assembly version. This is probably good practice as having a file version that is different to the assembly version will cause confusion.

If the AssemblyFileVersionAttribute is not supplied, the AssemblyVersionAttribute is used for the Win32 file version that is displayed on the Version tab of the Windows file properties dialog.

You can set the assembly version using the AssemblyVersionAttribute.

Assembly attributes are usually applied in the AssemblyInfo.cs file as stated in the other answers.

Scott Munro
  • 13,369
  • 3
  • 74
  • 80
  • I just saw a good argument for not synchronizing the file and assembly versions... http://freetodev.spaces.live.com/blog/cns!EC3C8F2028D842D5!1253.entry?wa=wsignin1.0&sa=191639258 – Scott Munro Nov 08 '10 at 09:46
11

Right click the project and click properties. The properties window will appear. In that click Application tab. It will show application information of the project. There will be a button named Assembly Information. click the button, it will show you a form containing assembly information of the project. You can specify the assembly version (contains four text boxes, i.e., Major Version, Minor Version, Build Number, Revision). It will store the assembly details in AssemblyInfo.cs of the corresponding project.

Kumaran T
  • 617
  • 1
  • 9
  • 24
6

You can set the version number in AssemblyInfo.cs.

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Note that the assembly version is not the same as the assembly file version. From your brief description it sounds more like you are looking for the latter - AssemblyFileVersion.

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
5

Alter this line in AssemblyInfo.cs:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
[assembly: AssemblyVersion("1.9.10292.8")]
Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • 5
    Suppose Now, I want to auto increment it from here on. I mean after next build it should be "1.9.10293" How to achieve that. – Unbreakable Jan 16 '17 at 21:37
  • @Unbreakable you could write a console application that reads the AssemblyInfo.cs file into lines (`string[]`), looks for a line that starts with `[assembly: AssemblyVersion("`, parses the following substring until `")]` into a `new Version()`, increment the build, then replace the line with `[assembly: AssemblyVersion(\"" + myVersion.ToString() + "\")]` and write all lines back to the file. You can call the application in Build Events (in your Project Properties), supplying the path using `$(ProjectDir)` to give your console app the project directory where to look for the AssemblyInfo file – Ben Philipp Dec 27 '19 at 12:58
0

If you need to change it on visual studio open your solution file then right click and select properties then select Application on that select assembly information than change version on assembly. enter image description here