Hi,I'm getting a "assembly or one of its dependancies could not be found"
error when running the code below.The code works fine when called by a .NET
program, but fails when called by an assembly instantiated in Excel 2000.
The CreateInstanceFromAndUnwrap looks for the assembly in Excel's "Default
file location" setting, even though the correct path is set by
setup.ApplicationBase.
What am I doing wrong?
Thanks.Francis Gingras
// Get reflection permission
ReflectionPermission reflectionPerm = new
ReflectionPermission(PermissionState.None);
reflectionPerm.Flags = ReflectionPermissionFlag.MemberAccess;
// Get file permissions
FileIOPermission fileperm = new FileIOPermission(FileIOPermissionAccess.Read
| FileIOPermissionAccess.PathDiscovery,
Path.GetDirectoryName(Assembly.GetExecutingAssembl y().Location));
fileperm.Assert();
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y().Location);
Evidence evidence = AppDomain.CurrentDomain.Evidence;
adapterDomain = AppDomain.CreateDomain("MyApp.Adapter", evidence, setup);
ILoader loader = (ILoader)
adapterDomain.CreateInstanceFromAndUnwrap("c:\bin\ MyApp.dll",
"MyApp.Loader");