I have an application which programatically builds and compiles DLLs using Codedom. I am building the source code using a stringbuilder and then using the CompileAssemblyFromSource option to compile the DLL. I would like to be able to set the AssemblyVersion attribute for my generated DLL so that I can right-click on the DLL and see the version number property listed. Currently it just shows as version 0.0.0.0. It would be nice to set the other attributes as well, my I'm mostly concerned with the version number.
So far in my research I see references to objects such as the CodeAttributeDeclaration, but can't find any good sample code and can't figure out how to set the version number for the assembly.
Any help would be appreciated. Thanks.

Generating code via codedom and assigning version to assembly
Dan_12345
N2H
The syntax for the version attribute is[assembly: AssemblyVersion("5.4.3.21")]You should add it after any using statements, but outside of any namespaces. You get a compiler error if you include an assembly-level attribute inside a namespace.
SDY
string versionn = "5.4.3.21";
CodeAttributeArgument arg = new CodeAttributeArgument(new CodePrimitiveExpression(version));
CodeAttributeDeclaration attribute = new CodeAttributeDeclaration("System.Reflection.AssemblyVersionAttribute", arg);
compileUnit.AssemblyCustomAttributes.Add(attribute);
Assembly-level attributes get added using the AssemblyCustomAttributes property of the CodeCompileUnit, as shown above. Regular attributes would get added using the CustomAttributes property of whatever you're adding the attribute to (CodeTypeDeclaration, CodeMemberMethod, etc.).
Conor Morrison - MSFT
Once I do the code shown above, what do I do with it