Re: How do i dynamicaly load and unload a C# dll at runtime

From: Daniel (softwareengineer98037_at_yahoo.com)
Date: 11/30/04


Date: Mon, 29 Nov 2004 16:22:47 -0800

how do i access methods when the .net assembly was loaded with late biding?

class Class1
{
 public static void Main()
 {
  System.Reflection.Assembly SampleAssembly;
  SampleAssembly =
System.Reflection.Assembly.LoadFrom("C:\\SimpleSolutions\\asmload\\asmtoload
\\bin\\Debug\\asmtoload.dll");
  System.Type[] Types = SampleAssembly.GetTypes();
  foreach (System.Type oType in Types)
  {
   System.Console.WriteLine(oType.Name.ToString());
   string strName = oType.Name.ToString();
   System.Object pObj = SampleAssembly.CreateInstance("asmtoload" + "." +
strName);
   //System.Console.WriteLine(pObj.IOCTL("foo")); THIS IS A BUILD ERROR
BECAUSE IOCTL method is not accessible, how to access method if type info of
dynamicaly loaded dll?
   System.Threading.Thread.Sleep(5000);
  }

 }
}

"John M Deal" <johndeal@necessitysoftware.com> wrote in message
news:ukhu00m1EHA.2804@TK2MSFTNGP15.phx.gbl...
> To load you'll want to look at the System.Reflection.Assembly.LoadFrom
> method in the reflection classes. To unload though you'll need to learn
> about creating Application Domains. When you load a dll, you can't
> unload it until the application domain that hosts it is unloaded (at
> least in my experience). If you spawn a new application domain then load
> your dll, the dll can be unloaded when the application domain is
> unloaded. Specifically look at the System.AppDomain.CreateAppDomain and
> System.AppDomain.Unload methods. Hope that will get you started down the
> right path.
>
> Have A Better One!
>
> John M Deal, MCP
> Necessity Software
>
>
> Daniel wrote:
> > How do i dynamicaly load and unload a C# dll at runtime
> >
> >



Relevant Pages

  • Re: Delete dll
    ... >I want to unload the dll after use so I can delete the stored .dll file from ... >How do I unload the dll, or release the file so it may be deleted? ... You can explicitly load the library before calling anything in it ...
    (microsoft.public.vb.com)
  • Re: Delete dll
    ... >I want to unload the dll after use so I can delete the stored .dll file from ... >How do I unload the dll, or release the file so it may be deleted? ... You can explicitly load the library before calling anything in it ...
    (microsoft.public.win32.programmer.ole)
  • C# DLL unloading appdomain
    ... I've finally managed to remotely load a DLL. ... The host application always keeps the entry DLL in memory. ... also unload this main DLL? ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: OT: Need advice for building large applications.
    ... reflection to load the dll that you are interested in (see the ... replace the test DLLs at runtime and the application will unload the ... >>> You can have a class called Customer, put your method related to customers ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Poser? What happens to empty pages in a database unload/load?
    ... At my company, several time each weekend, a database is unloaded at ... squeezed out of the load. ... I unload the table and load it back and now all those empty pages are ... Art S. Kagel ...
    (comp.databases.informix)