简体   繁体   English

动态创建的dll没有版本号

[英]Dynamically created dll does not have version numbers

I would like to know, how can i assign version numbers to dynamically created dlls. 我想知道,如何为动态创建的dll分配版本号。 I have a mini application that creates dlls for my end users. 我有一个微型应用程序,可以为最终用户创建dll。 But currently, all the dlls created are having 0.0.0.0 as their version numbers. 但是当前,所有创建的dll的版本号都为0.0.0.0。

And it is difficult to keep track of the latest one. 而且很难跟踪最新的。 Is there are way to assign version numbers to dynamically created dlls. 有没有办法将版本号分配给动态创建的dll。 I tried searching the net but no avail. 我尝试搜索网络,但无济于事。

Please do advise. 请指教。 I am using the following code create the dlls. 我正在使用以下代码创建dll。

 // 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)

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{}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM