How to save a DLL created by the AssemblyBuilder to a specific directory

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I'm using some sample code from the msdn sample project:
http://download.microsoft.com/downl...echnologies/Reflection/ReflectionEmit.zip.exe

I'm using the 'AssemblyBuilder.Save' method, however, it takes a file name
as a parameter and I dont see any documentaion on how to define the
path/target location to write the file to. Here's a snippet of my code:

Dim TCA As New TestCreateAssembly
Dim [assembly] As AssemblyBuilder
[assembly] = CType(TCA.CreateCallee(Thread.GetDomain(),
AssemblyBuilderAccess.Save).Assembly, AssemblyBuilder)
[assembly].Save("EmittedAssembly.dll")

How do I determin exactly where to write "EmittedAssembly.dll" to?

Thanks.
 
Thanks.
I looked through the sample but didn't see where you could specify a
particular directory to save the dll into. I already have code that saves
the dll to disk, but it writes it into the same directory where the other
assembly dlls are. I want to specify a completely different directory which
could be on a different drive.
 
Hi moondaddy,

The DefineDynamicAssembly method is overloaded. You can specify the path.
For example, you can use the following to create the AssemblyBuilder. The
dll will be written to c:\

Dim a As AssemblyBuilder =
Thread.GetDomain().DefineDynamicAssembly(New AssemblyName("aaa"),
AssemblyBuilderAccess.RunAndSave, "c:\")

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top