Reflection.Emit question

  • Thread starter Thread starter Jeff Johnson
  • Start date Start date
J

Jeff Johnson

When creating types with Reflection.Emit, is it possible to define
namespaces? I've just begun to delve into this functionality and I saved one
of my dynamic assemblies to disk. Then I referenced it in a project and
viewed it in the object browser. The types I created were directly
underneath the assembly icon in the tree view as opposed to there being a
namespace icon.

Ultimately, I'm trying to reference a type I've created in this dynamic
assembly by specifying its type name as a string and using...oh, damn. I
just remembered reading about Type.GetType() and how it can't return types
from dynamic assemblies that haven't been saved to disk. Crap.

Well, just for curiosity's sake, does anyone know the answer to the first
question?
 
When creating types with Reflection.Emit, is it possible to define
namespaces? I've just begun to delve into this functionality and I saved one
of my dynamic assemblies to disk. Then I referenced it in a project and
viewed it in the object browser. The types I created were directly
underneath the assembly icon in the tree view as opposed to there being a
namespace icon.

I think you just create the entire class name with a namespace. So if
you wanted a namespace called "JJ" and a class called "Auto", you'd emit
a class called "JJ.Auto".
 
I think you just create the entire class name with a namespace. So if
you wanted a namespace called "JJ" and a class called "Auto", you'd emit
a class called "JJ.Auto".

Bingo! Worked perfectly. I never would have thought of such a simple thing.
 
Back
Top