[Mono-dev] Embedded mono: first on disk dynamic assembly stays locked, while others do not.

BaSS bassraf at gmail.com
Mon Aug 25 13:21:00 EDT 2008

Hi Guys,

I'm using the mono embedding API and I'm using a construction like this:

1) Setup Mono (2.0 beta or 1.9.1)
2) Load main Assembly
3) Create the script compiler object from the main assembly
4) Invoke the managed scriptcompiler with a script(string) and have the assembly written to disk using a semi-random name
5) from the unmanaged side, load the assembly from disk by its name mono_domain_assembly_open() into a new domain (mono_domain_create)
6) do something with the assembly (run a method)
7) use mono_domain_free() on the newly created secondary domain (from step 5)
8) goto step 4 for the other scripts

The problem is, the FIRST assembly written to disk stays locked and can't be overwritten nor deleted.
But when I repeat step 4 to 5 with a new filename, this file can be deleted without any problem.

My conclusion would be: 
1) normally a dynamically compiled assembly written to disk and loaded by mono_domain_assembly_open() can be deleted.
2) only the first time the mono runtime keeps a lock on the created on disk assembly

Note: I'm not using the CompilerResults.CompiledAssembly property which would cause the assembly to get loaded in the current (compiler) domain.

Is this a bug or is there something being loaded initialized only the first time I compile the dynamic assembly?


More information about the Mono-devel-list mailing list