Method in compiled assembly throws exceptions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David Rutten
    New Member
    • Oct 2008
    • 1

    Method in compiled assembly throws exceptions

    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. CompileAssembly FromSource()
    3) I use Assembly.GetTyp e() to get the type code for the 'script' class in these assemblies.
    4) Then I make a new instance of this type using System.Activato r.CreateInstanc e()
    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 CompilerParamet ers() 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
Working...