M.A
M.A

Reputation: 1133

Dynamically created dll does not have version numbers

I would like to know, how can i assign version numbers to dynamically created dlls. I have a mini application that creates dlls for my end users. But currently, all the dlls created are having 0.0.0.0 as their version numbers.

And it is difficult to keep track of the latest one. Is there are way to assign version numbers to dynamically created dlls. I tried searching the net but no avail.

Please do advise. I am using the following code create the dlls.

 // Setup for compiling
         var provider_options = new Dictionary<string, string>
                     {
                         {"CompilerVersion","v3.5"}
                     };
         var provider = new Microsoft.CSharp.CSharpCodeProvider(provider_options);

         var compiler_params = new System.CodeDom.Compiler.CompilerParameters();

         string outfile = @"D:\EDUnit.dll";
         compiler_params.OutputAssembly = outfile;
         compiler_params.GenerateExecutable = false;
         compiler_params.ReferencedAssemblies.Add("System.dll");


         // Compile
         var results = provider.CompileAssemblyFromSource(compiler_params, strbase)

Upvotes: 0

Views: 78

Answers (1)

Leo
Leo

Reputation: 14830

You need to assign it to your source code file using reflection attributes. The code provider will look for it, extract it and add the required metadata. Decorate your source class as follows

using System.Reflection;

[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
public class Your_Class{}

Upvotes: 1

Related Questions