AppDomains and Dynaimc Loading problem

  • Thread starter Thread starter Guest
  • Start date Start date
Hi,

I remember there are two solutions:

a) Playing with AppDomainSetup and AppDomain properties to ensure proper
values of PrivateBinPath and other properties used by the Fusion assembly
loader to locate assemblies.

b) Attaching a handler to the AssemblyResolve event and loading a requested
assembly with Assembly.LoadFrom from a known location.
 
Hey Dmitriy,

I've been working with your first solution idea. The problem is, as I
belive I stated in the first post, it seems to me that even though I'm
unwrapping the loader in the new appdomain the remote loader, when I use the
AppDomain.CurrentDomain.BasePath it returns the base path of the AppDomain
the main application is running in, and not the new AppDomain I created the
loader in. Also, when I force load the path into the loader it returns a
serialization error stating that it doesn't have enough information or some
such.

Again, this is just driving my crazy trying to figure it out.

Sincerely,

Jon

Dmitriy Lapshin said:
Hi,

I remember there are two solutions:

a) Playing with AppDomainSetup and AppDomain properties to ensure proper
values of PrivateBinPath and other properties used by the Fusion assembly
loader to locate assemblies.

b) Attaching a handler to the AssemblyResolve event and loading a requested
assembly with Assembly.LoadFrom from a known location.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

JonS. said:
Hi,

I posted this article (
http://msdn.microsoft.com/newsgroup...e9781a-78f7-4398-a0ef-eeb195eccaea&sloc=en-us
) last week, and have yet to receive any replies. If someone could please
give me further information I would greatly appreciate it.

Sincerely,

Jon
 
Jon,

As far as I remember, when you load an assembly to an AppDomain, you have to
load all referenced assemblies as well. Handling the AssemblyResolve event
really helps in troubleshooting such problems, and this is the approach I'd
recommend you tried.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

JonS. said:
Hey Dmitriy,

I've been working with your first solution idea. The problem is, as I
belive I stated in the first post, it seems to me that even though I'm
unwrapping the loader in the new appdomain the remote loader, when I use
the
AppDomain.CurrentDomain.BasePath it returns the base path of the AppDomain
the main application is running in, and not the new AppDomain I created
the
loader in. Also, when I force load the path into the loader it returns a
serialization error stating that it doesn't have enough information or
some
such.

Again, this is just driving my crazy trying to figure it out.

Sincerely,

Jon

Dmitriy Lapshin said:
Hi,

I remember there are two solutions:

a) Playing with AppDomainSetup and AppDomain properties to ensure proper
values of PrivateBinPath and other properties used by the Fusion assembly
loader to locate assemblies.

b) Attaching a handler to the AssemblyResolve event and loading a
requested
assembly with Assembly.LoadFrom from a known location.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

JonS. said:
Hi,

I posted this article (
http://msdn.microsoft.com/newsgroup...e9781a-78f7-4398-a0ef-eeb195eccaea&sloc=en-us
) last week, and have yet to receive any replies. If someone could
please
give me further information I would greatly appreciate it.

Sincerely,

Jon
 
If the base directory of your new domain is not a sub-directory of the
existing domain then you will have problems with this code "as is", but it
should give you the pointers you need [no pun]. The problem with this is
that the loader class needs to be accessible from both assemblies, and it
also has the issue that is a 'dll' is located in both the main directory and
the sub-directory then the main one will load first (yeah, should not
happen, but I have seen users drag copies of old files all over the place).

Did'nt see you post until now - but if you are still getting stuck continue
the thread as I will put a watch point against it.
Not an expert by no means, but ...

- Colin.
 
Back
Top