Callbacks/Loading Assemblies

Jan 13, 2010 at 8:50 PM


I was wondering if it was supported to supply a callback function to a constructor.  Like this code does when creating a ResolveEventHandler. I would like to use it to load an assembly

in an arbitrary location using the AppDomain like

        private void Form1_Load(object sender, EventArgs e)
//The AssemblyResolve event is called when the common language runtime tries to bind to the assembly and fails.
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(currentDomain_AssemblyResolve);

       Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{ ...}

Also, when loading an assembly, I think I am supposed to put the dll into the C:\Program Files\IronScheme directory? I tried something like
(clr-reference "Core") (clr-using "Core") (new Core.Aut) but it throws an error saying it cant find the type. Also, is it supposed to throw an error when i referencce a non-existing


Jan 13, 2010 at 8:52 PM

Scratch the first question. I just realized that clr-event-add! exists


Jan 13, 2010 at 9:34 PM

Sorry. Found the answer.

 (ironscheme clr)
 (net shorthand))

 AppDomain AssemblyResolve
 (% AppDomain.CurrentDomain)
 (lambda (sender args)
    (display "BOO")
    (: System.Reflection.Assembly.LoadFrom "C:/Program Files/IronScheme/Core.dll")))

(use Core)
(new Core.CoreAutClass)

net shorthand basically is my library which passes #f everything, invoking reflection and defines some shortcuts. I was having some problems when i had the dll named

to Interop.Core but when i renamed it it apparently worked out.