Hi,
I found a solution...
ICodeCompiler comp = new VBCodeProvider().CreateCompiler();
It seems the VBCodeProvider() does understand the imports correctly, and
happily signs and versions my generated assembly.
Changing to the C# compiler returns the error about the missing reference:
ICodeCompiler comp = new CSharpCodeProvider().CreateCompiler();
Is this a bug or expected behaviour ?
Changing the compiler should not make a difference should it ?
kr,
Michel.
On Sat, 26 Jul 2003 18:15:55 -0400, Michel Liesmons
<[EMAIL PROTECTED]> wrote:
>Hi,
>
>I've been creating a DLL on the fly using CodeDOM.
>Now I would like to assign a version and a strong name.
>
>The code below adds the attributes, but the compilation fails.
>I'm missing an import.
>
>If I add the imports, it still does not work.
>
>The code being generated 'imports' inside the namespace, whereas the
>Assembly attributes are specified outside the namespace (as they should).
>
>Anybody any ideas on how to do this ?
>
>Thanks in advance.
>
>Michel.
>
>
> CodeCompileUnit ccu = new CodeCompileUnit();
>
> ccu.AssemblyCustomAttributes.Add (new CodeAttributeDeclaration
>("AssemblyKeyFile", new CodeAttributeArgument (new CodePrimitiveExpression
>("CICSBank.snk"))));
>
> ccu.AssemblyCustomAttributes.Add (new CodeAttributeDeclaration
>("AssemblyVersion", new CodeAttributeArgument (new CodePrimitiveExpression
>("1.1.0"))));
>
> m_ns = new CodeNamespace (t.Namespace);
> ccu.Namespaces.Add (m_ns);
> m_ns.Imports.Add (new CodeNamespaceImport ("System"));
> m_ns.Imports.Add (new CodeNamespaceImport ("System.Reflection"));