Hello,
this is a bit of a complicated issue, I'll try to be succinct.
1) my application allows people to add 'scripts' to it.
2) these scripts are written in VB.NET or C#.NET language, and they are compiled into memory-assemblies on the fly using VBCodeProvider.CompileAssemblyFromSource()
3) I use Assembly.GetType() to get the type code for the 'script' class in these assemblies.
4) Then I make a new instance of this type using System.Activator.CreateInstance()
5) finally I cast this System.Object to an Interface I know it implements and call methods on this instance.
This all works fine.
Now, I added the option for users to add reference assemblies to these scripts. They pick a dll somewhere off the disk, and I add that file path to the CompilerParameters() field. The compile operation still works fine (no compiler errors or warnings), but as soon as I try and call a method on the instantiated type, I get the following error:
"Could not load file or assembly 'MathSeries, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified"
The MathSeries dll is just something I made to test this feature. It's a bog-standard Class Library with a single class which has the default references as set up by VS2005.
I tried handling the ModuleResolve event on the assembly, but it's never called.
Any ideas are most welcome.
Thanks,
David
--
David Rutten