Re: Assembly dependancies

Discussion in 'ASP .Net' started by Roy Osherove, Jun 28, 2003.

  1. Roy Osherove

    Roy Osherove Guest

    I've written a small plugins demo that uses a temp AppDomain to load
    Assemblies and check whether they contain types that implement a certain
    plug-in, and then unloads those assemblies by unloading that AppDomain.
    Perhaps it will help:

    http://weblogs.asp.net/rosherove/story/8048.aspx


    --
    Regards,

    Roy Osherove
    http://www.iserializable.com
    ---------------------------------------------

    "Shawn Farkas [MS]" <> wrote in message
    news:...
    > Hi Richard,
    >
    > What problems are you having with your application? Why specifically
    > doesn't this work? A good reference for various assembly load questions

    is
    > Suzanne Cook's blog:
    > http://blogs.gotdotnet.com/suzcook/
    >
    > -Shawn
    > --
    >
    > --------------------------------------------------
    > This posting is provided "AS IS" with no warranties, and confers no rights
    > "Richard Sutcliffe" <> wrote in message
    > news:...
    > > I've written a method to verify that a given assemblies references are
    > > installed using Assembly.Load & LoadFrom. Unfortunately, due to the

    fact
    > > that there is no Assembly.Unload method, subsequent calls cannot be
    > > trusted
    > > as the references have been loaded into memory. I've found a couple of
    > > newsgroup postings that mention creating a temporary AppDomain and using

    a
    > > MarshalByRefObject class in order to access these objects across
    > > application
    > > domain boundaries, however none of the examples that go with these
    > > postings
    > > work.
    > >
    > > Below is the code I've got the closest with, I'd be grateful if anyone

    can
    > > point out what I'm doing wrong.
    > >
    > > Thanks in advance.
    > >
    > >
    > > public class AssemblyLoader: MarshalByRefObject
    > > {
    > > Assembly assembly;
    > >
    > > public Assembly Load(AssemblyName assemblyRef)
    > > {
    > > assembly = System.Reflection.Assembly.Load(assemblyRef);
    > > return assembly;
    > > }
    > >
    > > public Assembly LoadFrom(string name)
    > > {
    > > assembly = System.Reflection.Assembly.LoadFrom(name);
    > > return assembly;
    > > }
    > > }
    > >
    > > public void CheckDLLDependancies(string filename)
    > > {
    > > System.Security.Policy.Evidence evidence =
    > > AppDomain.CurrentDomain.Evidence;
    > > System.AppDomainSetup setup =
    > > System.AppDomain.CurrentDomain.SetupInformation;
    > >
    > > // Create the AppDomain
    > > AppDomain dependancyDomain = AppDomain.CreateDomain(filename,
    > > evidence, setup);
    > >
    > > AssemblyLoader loader = (AssemblyLoader)
    > >

    dependancyDomain.CreateInstanceFromAndUnwrap(typeof(AssemblyLoader).Assembly
    > > .Location, typeof(AssemblyLoader).FullName);
    > >
    > > // attempt to load the initial assembly
    > > Assembly ma = loader.LoadFrom(filename); // ma ALWAYS RETURNS
    > > NULL!!!!!
    > >
    > > // get the assembly reference names
    > > AssemblyName[] names = ma.GetReferencedAssemblies();
    > >
    > > //.............
    > > }
    > >
    > >
    > > ---
    > > Outgoing mail is certified Virus Free.
    > > Checked by AVG anti-virus system (http://www.grisoft.com).
    > > Version: 6.0.487 / Virus Database: 286 - Release Date: 1/6/2003
    > >
    > >

    >
    >
     
    Roy Osherove, Jun 28, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Myers

    Compile dependancies into a .NET app

    Jason Myers, Feb 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    Ken Halter
    Feb 23, 2006
  2. =?Utf-8?B?VzFsZDBuZTc0?=

    COM+ Dependancies: System.IO.FileNotFoundException

    =?Utf-8?B?VzFsZDBuZTc0?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    632
    =?Utf-8?B?VzFsZDBuZTc0?=
    Apr 28, 2005
  3. =?Utf-8?B?VzFsZDBuZTc0?=

    COM+ Dependancies: System.IO.FileNotFoundException

    =?Utf-8?B?VzFsZDBuZTc0?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,001
    =?Utf-8?B?SmFtZXMgTWFob25leQ==?=
    May 5, 2005
  4. mwt

    Finding Module Dependancies

    mwt, Apr 21, 2006, in forum: Python
    Replies:
    7
    Views:
    302
    robert
    Apr 23, 2006
  5. Kevin Watt

    auto-reload changed dependancies

    Kevin Watt, Oct 17, 2004, in forum: Ruby
    Replies:
    1
    Views:
    93
    Michael Neumann
    Oct 17, 2004
Loading...

Share This Page