Appdomain cannot load assembly... why?

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

Hi, (My code is at the end of this post)

I have an AppDomain that must load a simple assembly that has only one class
with one method and it does not work... I receive this exception : "Could
not load file or assembly 'ModuleLoader.dll' or one of its dependencies. The
system cannot find the file specified."

Does anyone have an idea of something I'm missing?

Thanks

ThunderMusic

Code:
*** Main App (calling method) ***
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
ads.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
ads.DisallowBindingRedirects = false;
ads.DisallowCodeDownload = true;
m_CurrentMonitorAppDomain = AppDomain.CreateDomain("MonitorLoader", null,
ads);
// The following call fails
MonitoringModuleLoader mml =
(MonitoringModuleLoader)m_CurrentMonitorAppDomain.CreateInstanceAndUnwrap("ModuleLoader.dll",
"ModuleLoader.MonitoringModuleLoader");

*** The "ModuleLoader" library ***
namespace ModuleLoader
{
public class MonitoringModuleLoader : MarshalByRefObject
{
public MonitoringModuleLoader()
{
}
public MonitorBase Load(byte[] LibBytes, string ModuleName)
{
return null;
}
}
}
 
finally, I found the problem... I was using 'CreateInstanceAndUnwrap' and
should have used 'CreateInstanceFromAndUnwrap'

Thanks
 
Back
Top