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

BaSS bassraf at gmail.com
Mon Aug 25 16:17:00 EDT 2008


Thanks for you answers Robert,

please see my replies below:

> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of Robert Jordan
> Sent: Monday, August 25, 2008 20:38
> To: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Embedded mono: first on disk dynamic assembly
> stays locked, while others do not.
> 
> BaSS wrote:
> > 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
> 
> Why are you performing 5-8 from unmanaged code? This can be done much
> easier and less error-prone in managed code.
> 

Well, I'm having a weird problem when running code within the main assembly when calling it from the unmanaged side. When I call the same code using a test app in sharpdevelop, it works.
The managed code that fails when executed from the API is "AppDomain.CreateDomain("sandbox");" I get a stackoverflow in the mono.dll and everything comes to a halt. (all the other code works, just the createdomain fails..)
 
So... the only way for me to get the assembly to load into a new domain (so I can discard the entire domain later for unloading the assembly) is the unmanaged mono_domain_assembly_open();
I'd rather do it from the managed side, but the stackoverflow prevents me from doing so.


> > The problem is, the FIRST assembly written to disk stays locked and
> can't be overwritten nor deleted.
> 
> Windows?
> 

Yes, Windows ;)

> > Is this a bug or is there something being loaded initialized only the
> first time I compile the dynamic assembly?
> 
> It's most likely in your code, as a simple managed proof of concept
> does
> not expose this bug.

I tried removing all optimizations which prevent objects from being created twice, so all compiler objects etc now get recreated every call.. and the problem still exists.. I stripped it all to the bare minimum.. only the first time the compiler writes an assembly to disk, it gets locked and it won't let go.

 
> Robert

Thank you Robert,
Bas

> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list


More information about the Mono-devel-list mailing list