Accessing assemblies from an unmanaged host -
06-07-2006
, 10:38 AM
We are implementing a .NET runtime host in an unmanaged application written
in Borland Delphi. The application initializes a host, creates a new
application domain and then instantiates a class in a .NET assembly using the
new AppDomain.
Everything works fine as long as the .NET assembly to load is located
locally on the machine running the host application (the Delphi application).
If the .NET assembly is located on a network resource, the class inside the
assembly cannot be intantiated. No specific exception is thrown, but the
unwrapped object is not of the expected type. I believe this problem is
related to security in .NET. I hope that there will be someone to give me a
tip.
The code used to load the assembly looks as the following:
//Create and start a dot Net Host
Host := TJclClrHost.Create('', hfWorkStation, True, [hlOptSingleDomain]);
Host.Start;
//Create an application domain in the new host
AppDomainSetup := Host.CreateDomainSetup;
AppDomainSetup.ApplicationBase := ExtractFilePath(ADotNetAssemblyUnc);
AppDomain := Host.CreateAppDomain('myAppDomain');
//Create an instance of the dot Net class
obj := IUnknown(AppDomain.CreateInstanceFrom(
ADotNetAssemblyUnc, ADotNetClassName)) as IOBjectHandle;
//Unwrap plugin object
obj.Unwrap(UnwrappedObject);
--
Anders Evensen |