D
David McCabe
I have an ATL component which uses MC++ /clr to talk to .NET components. Due
to the limitations of the (native) client, the COM server is located outside
the appbase, and there can be no configuration files.
Now, when the component is instantiated, all is well, right up to the point
at which I instantiate an object in another .NET assembly (located in the
same directory as the ATL DLL). Then I predictably get a
FileNotFoundException - because it's looking in the appbase of the client,
not the server.
I've tried using AppendPrivatePath, and I predictably get the "outside
appbase" error, as usual. So, I concluded that the only way to do this is to
preload the assemblies on which I depend.
Why doesn't this work, then?
String *dir =
Path::GetDirectoryName(System::Reflection::Assembly::GetCallingAssembly()->Location);
String *filename = Path::Combine(dir, String::Concat(name, S".dll"));
Assembly *assemblyFromFile = Assembly::LoadFrom(filename);
Assembly *assemblyFromStrongName =
AppDomain::CurrentDomain->Load(assemblyFromFile->FullName);
It's illustrative, but the principle is the same. I can load the assembly
just fine, but that doesn't resolve the dependency in the application. When
the loader tries to load the dependency - like the last line in those four -
as I understand it, it should use the previously loaded assembly, rather
than searching for it anew. It doesn't.
Any light?
David
to the limitations of the (native) client, the COM server is located outside
the appbase, and there can be no configuration files.
Now, when the component is instantiated, all is well, right up to the point
at which I instantiate an object in another .NET assembly (located in the
same directory as the ATL DLL). Then I predictably get a
FileNotFoundException - because it's looking in the appbase of the client,
not the server.
I've tried using AppendPrivatePath, and I predictably get the "outside
appbase" error, as usual. So, I concluded that the only way to do this is to
preload the assemblies on which I depend.
Why doesn't this work, then?
String *dir =
Path::GetDirectoryName(System::Reflection::Assembly::GetCallingAssembly()->Location);
String *filename = Path::Combine(dir, String::Concat(name, S".dll"));
Assembly *assemblyFromFile = Assembly::LoadFrom(filename);
Assembly *assemblyFromStrongName =
AppDomain::CurrentDomain->Load(assemblyFromFile->FullName);
It's illustrative, but the principle is the same. I can load the assembly
just fine, but that doesn't resolve the dependency in the application. When
the loader tries to load the dependency - like the last line in those four -
as I understand it, it should use the previously loaded assembly, rather
than searching for it anew. It doesn't.
Any light?
David