I have successfully created a class that inherits from MarshallByRefObject.
The above class also implements an interface and is invoked remotely from the main AppDomain. DTOs were also created to ferry information accross.
I have verified as much from the debugger, both on the remote class and the calling domain that the remotely loaded assemblies are not being loaded into the main AppDomain. Again, the remote types/assemblies are not bleeding into the Main AppDomain, verified via a Debug Watch into the AppDomain.CurrentDomain.GetAssemblies()
.
AppDomain.CurrentDomain.GetAssemblies().Count() //From inside the remote object
121
AppDomain.CurrentDomain.GetAssemblies().Count() //At the client, after RPC call.
13
The remote/temp domain then gets offloaded.
However, I still cannot delete any dll's that was read in the remote domain, what am I missing?
I have also experimented with the variation of:
AppDomain.CurrentDomain.Load(File.ReadAllBytes(_.FullName))
and
Assembly.LoadFrom(_.FullName)
Whichever one I use, the files are still being locked even though as far as I can tell, the assemblies were remotely loaded, and offloaded.