Appdomain cannot load assembly... why?

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;
}
}
}
 
T

ThunderMusic

finally, I found the problem... I was using 'CreateInstanceAndUnwrap' and
should have used 'CreateInstanceFromAndUnwrap'

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top