In my code, I create a DLL dynamically. The following code is what I use to create my DLL:
/// <summary>
/// See CodeDom example hon how its used
/// </summary>
/// <param name="source_code"></param>
/// <param name="assemblies"></param>
/// <param name="generate_executable"></param>
/// <param name="compiler_options"></param>
/// <param name="output"></param>
/// <returns></returns>
public static Tuple<Assembly, string> CompileSource(string source_code, List<string> assemblies, bool generate_executable = false, string compiler_options = "/optimize", string output_assembly = "")
{
CompilerParameters compilerParams = null;
CSharpCodeProvider provider = null;
CompilerResults result = null;
string errors = string.Empty;
try
{
provider = new CSharpCodeProvider();
compilerParams = new CompilerParameters();
foreach (var entry in assemblies)
{
compilerParams.ReferencedAssemblies.Add(entry);
}
if (output_assembly != string.Empty)
compilerParams.OutputAssembly = output_assembly;
compilerParams.GenerateExecutable = generate_executable;
compilerParams.GenerateInMemory = false;
compilerParams.IncludeDebugInformation = true;
compilerParams.CompilerOptions = compiler_options;
result = provider.CompileAssemblyFromSource(compilerParams, source_code);
foreach (CompilerError error in result.Errors)
{
errors += String.Format("{0}({1},{2}: error {3}: {4}", error.FileName, error.Line, error.Column, error.ErrorNumber, error.ErrorText);
}
}
catch (Exception err)
{
}
return Tuple.Create(result.CompiledAssembly, errors);
}
What I would like to do is add Assembly Information like the company, product, title, etc. Looking at this site and site to add it but I'm not sure how to do it.
The CompilerParameters doesn't seem to give an option to add these attributes.
Anyone have a suggestion if it can be done on how to add this information?
Thanks