I am creating an assembly at runtime with CSScriptLibrary. Everything works fine, but my resulting assembly does not have the required assembly information.
If I include the assembly information attributes (found in AssemblyInfo.cs in every C# project) in the code-string the compilation fails with "duplicate attribute error".
Here is the code with which I create my assembly:
try
{
compiledResultAssembly = CSScriptLibrary.CSScript.LoadCode(code, assemblyReferences.ToArray());
}
catch(Exception ex)
{ }
How do I specify the assembly version so that the "compiledResultAssembly" is not in version 0.0.0.0?
The version of CSScriptLibrary is 3.11.1.0.
Thanks in advance
Edit 08.07.2019
I found the solution. The CSScriptLibrary injects a AssemblyDescription attribute at some point, which causes the "duplicate attribute" error.
To specify assembly version information simply use the following setup of you scriptcode:
using System.Reflection;
using System.Runtime.InteropServices;
// all your usings
[assembly: AssemblyVersion("1.2.3.4")]
[assembly: AssemblyFileVersion("1.2.3.4")]
namespace YourNamespace
{
// your code here
}
Note that the assembly attributes must be the first thing in your code an can not be placed anywhere else.