Loading Assemblies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John F

    #1

    Loading Assemblies

    Hello all,

    When dynamically loading classes through reflection using Assembly.LoadFr om
    I have the following questions:

    1) Once you load an assembly it doesn't appear you can unload it. If you
    try to load an assembly multiple times does this cause any type of memory
    issues?

    2) If you load an assembly and later you try to load a newer version of the
    same assembly, does .NET know it's the same assembly and if so, what happens?

    3) Before you execute Assembly.LoadFr om should you check to see if the
    assembly is already loaded to avoid loading it again and if so how?

    Thanks in advance,
    John F
  • Andreas Mueller

    #2
    Re: Loading Assemblies

    John F wrote:
    [color=blue]
    > Hello all,
    >
    > When dynamically loading classes through reflection using Assembly.LoadFr om
    > I have the following questions:
    >
    > 1) Once you load an assembly it doesn't appear you can unload it. If you
    > try to load an assembly multiple times does this cause any type of memory
    > issues?
    >
    > 2) If you load an assembly and later you try to load a newer version of the
    > same assembly, does .NET know it's the same assembly and if so, what happens?
    >
    > 3) Before you execute Assembly.LoadFr om should you check to see if the
    > assembly is already loaded to avoid loading it again and if so how?
    >
    > Thanks in advance,
    > John F[/color]

    see http://tinyurl.com/2r7g4
    1) Almost correct. You can only unload appdomains. What you can do is to
    create a new AppDomain and load you assembly into it. However, you also
    have to make sure to create your object inside the new domain using
    AppDomain.Creat eInstanceAndUnw rap(..).
    I haven't had any issues calling LoadFrom multiple times.

    2)If you have a string named assembly and the version is higher it will
    get loaded.

    3) see 1)

    HTH,
    Andy
    --
    To email me directly, please remove the *NO*SPAM* parts below:
    *NO*SPAM*xmen40 @*NO*SPAM*gmx.n et

    Comment

    Working...