Dynamically compiled assemblies and strong naming

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I am using the CSharpCodeProvider to dynamically compile an in-memory
assembly from some C# source, do I need to worry about signing this assembly
if I'm doing the compilation, instantiation, and invocation of a dynamic
object from a strongly named assembly?

If so, how do you strongly name a dynamic, in-memory assembly?
 
If I am using the CSharpCodeProvider to dynamically compile an in-memory
assembly from some C# source, do I need to worry about signing this assembly
if I'm doing the compilation, instantiation, and invocation of a dynamic
object from a strongly named assembly?

If so, how do you strongly name a dynamic, in-memory assembly?

There should not be any problem AFAIK as long as you do this dynamically
(as in post compilation, and not a reference, which surely is the case with
you, is it?), but if you want to do this,I think you can use

_compileUnit.AssemblyCustomAttributes.Add(new CodeAttributeDeclaration( ..)

to set

[assembly: AssemblyKeyFile("xyz.snk")]
[assembly: AssemblyKeyName("abc")]

Cheers,
Ranjan
 
There should not be any problem AFAIK as long as you do this dynamically
(as in post compilation, and not a reference, which surely is the case with
you, is it?),

Hmmm... actually I have a couple of different scenarios so I'm not sure.

1. From a strongly named assembly I need to take some runtime generated C#
code and compile to a DLL assembly on disk.

2. From the same strongly named assembly I need to generate some more C#
code, dynamically compile to an in-memory assembly *and* addref the assembly
I created in (1).

3. Again, from the original strongly named assembly I need to instantiate
objects in the assembly created in (2) and invoke their methods.

I'm just wondering whether I'm going to be running into problems with the
strong naming since it seems a strongly named assembly can only "reference"
other strongly named assemblies. It is unclear whether this extends to
dynamically compiled assemblies.
but if you want to do this,I think you can use

_compileUnit.AssemblyCustomAttributes.Add(new CodeAttributeDeclaration( ..)

to set

[assembly: AssemblyKeyFile("xyz.snk")]
[assembly: AssemblyKeyName("abc")]

Thanks, that might come in handy!!
Cheers,
Ranjan

-- TB
 
Back
Top