loading "private" assemblies

G

Guest

Hello

I emply a "plug-in" architecture for a .NET Windows service. At OnStart, the service browses for DLL's in in sub-folders and loads them dyanamically using Assembly.LoadFrom()

The service executable is placed in its own folder with the assemblies required for its successful complilation. Each plugin is also stored in its own folder with the associated assemblies required for its succesful compilation ( the bin/release folder contents are copied to the run-time destination.

My questions is/are: If the service uses a common Assembly (such as My Utils.dll) that is also used by one or more plugins, will the plugin run-time code be pointed to the already loaded assembly or will the one in its physical location be loaded with it? Suppose they were built using the exact same version of the common assembly? And lastly, is it possible to specify that each plugin "use" the assembly in its own folder and not one that may have been loaded previously
 
S

Sherif ElMetainy

Hello

I will answer your last question first. It is possible to create multiple
application domains and specify a different path for probing assemblies for
each application domain. This leads to the your first question, if you do
this the assemblies will be loaded multiple times.

I don't know what will happen without application domains but i think that
multiple copies will be loaded too.

Best regards,
Sherif

BillyMac said:
Hello -

I emply a "plug-in" architecture for a .NET Windows service. At OnStart,
the service browses for DLL's in in sub-folders and loads them dyanamically
using Assembly.LoadFrom().
The service executable is placed in its own folder with the assemblies
required for its successful complilation. Each plugin is also stored in its
own folder with the associated assemblies required for its succesful
compilation ( the bin/release folder contents are copied to the run-time
destination.)
My questions is/are: If the service uses a common Assembly (such as My
Utils.dll) that is also used by one or more plugins, will the plugin
run-time code be pointed to the already loaded assembly or will the one in
its physical location be loaded with it? Suppose they were built using the
exact same version of the common assembly? And lastly, is it possible to
specify that each plugin "use" the assembly in its own folder and not one
that may have been loaded previously?
 
S

Steven Cheng[MSFT]

Thanks for Sherif's suggestion.

Hi,

As for the first question that if we manually use Assembly.LoadFrom load a
certain assembly and then call a class or type within that assembly, how
will the runtime search the assembly?

Based on my understanding, I think the actual behavior depend on the
whether the two assmblies are exactly the same one. (it's full name ,
version, culture, ....).

Since your plugin is loaded into your windows service's main AppDomain,
yes? When it call a class or type w(which is in the common ultiy assembly
you mentioned), the runtime will first check the memory to see whether the
class/ type is already existed. This require complete match, include ,
type/class name, namespace, the certain assemly's full name(the type/class
is contained). If match, the runtime will use the one in memory, otherwise,
it will search the certain required assembly as normal( by order , GAC,
private path...).
Also, I think a simple test on this is more valuable. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
G

Guest

Hi - ok, thanks for the info. I will use that to do further tests. You may close this post.

best regards,

Bill
 
S

Steven Cheng[MSFT]

Thanks Bill,

I've also done some tests and found that the actual things a far away from
what I've expected originally. In fact, the Assembly.Load ,
Assembly.LoadFrom are quite different . Anyway, I think the following blog
will be helpful to you.

#Choosing a Binding Context
http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top