hi all,
here i got strucked on auto incrementation of version using c# ,iam trying to do it programatically but i could able to change version number in variables but iam not able to write it back as it is read only.Is there any alternative for this?.

my code is as follows.

string versionnum;
            int rev;
            int major;
            int minor;
            int build;
            Assembly assem = Assembly.GetExecutingAssembly();
            AssemblyName assemName = assem.GetName();
            applicationVersion = assemName.Version;
                                
            major = Convert.ToInt32(applicationVersion.Major);
            minor = Convert.ToInt32(applicationVersion.Minor);
            build = Convert.ToInt32(applicationVersion.Build);
            rev = Convert.ToInt32(applicationVersion.Revision) + 1;
            versionnum = major+"."+minor+"." + build + "." + rev;

You should be changing the version in the compile, not at runtime. Versions are read only at runtime.

think you got your revision number hardcoded probably if its not changing, take a look at your assemblyinfo.cs file

you can do this get revision to change automatically

[assembly: AssemblyVersion("1.1.1.*")]

Please anyone tell me how to increment version no at compile time.

I have tried by placing following line in assemblyinfo.cs file still its not working

[assembly: AssemblyVersion("1.0.0.*")]

Thanks for the replies, i got the solution. Actually it is incrementing but in my application more than one dll we are using,it is pointing to other dll. so , i have taken primary output assembly version and now it is giving inremented version no everytime.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.