Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 动态创建的dll没有版本号_C#_.net_Dll - Fatal编程技术网

C# 动态创建的dll没有版本号

C# 动态创建的dll没有版本号,c#,.net,dll,C#,.net,Dll,我想知道,如何为动态创建的DLL分配版本号。我有一个为最终用户创建DLL的迷你应用程序。但目前,所有创建的DLL的版本号都是0.0.0.0 而且很难跟踪最新的一次。是否有方法为动态创建的DLL分配版本号。我试着上网搜索,但没有用 请务必提出建议。我正在使用以下代码创建DLL // Setup for compiling var provider_options = new Dictionary<string, string>

我想知道,如何为动态创建的DLL分配版本号。我有一个为最终用户创建DLL的迷你应用程序。但目前,所有创建的DLL的版本号都是0.0.0.0

而且很难跟踪最新的一次。是否有方法为动态创建的DLL分配版本号。我试着上网搜索,但没有用

请务必提出建议。我正在使用以下代码创建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)
//编译的设置
var provider\u options=新字典
{
{“compilervision”,“v3.5”}
};
var provider=new Microsoft.CSharp.CSharpCodeProvider(provider\u选项);
var compiler_params=new System.CodeDom.compiler.CompilerParameters();
字符串输出文件=@“D:\EDUnit.dll”;
编译器_params.OutputAssembly=输出文件;
编译器_params.GenerateExecutable=false;
编译器参数referencedAssembly.Add(“System.dll”);
//编撰
var results=provider.compileasemblyfromsource(编译器参数,strbase)

您需要使用反射属性将其分配给源代码文件。代码提供者将查找、提取并添加所需的元数据。按照如下方式装饰您的源类

using System.Reflection;

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