Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. IDisposable, destructors and loaded assemblies

IDisposable, destructors and loaded assemblies

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Boaz V
    wrote on last edited by
    #1

    Hi, in my program, at the constructor of the main driver class, it loads about 6 DLLs (managed) using the Assembly.LoadFile method and then invoking the needed methods using reflections functions. Anyway, when i want to quit the program, sometimes some of the dlls can not be accessed since "they are in use by another program". I've checked the Windows Task Manager and my process do not appear there... any ideas guys? i thought maybe using Dispose procedure or a destructor. can anyone help me with deciding which road to take? and how? 10x

    K 1 Reply Last reply
    0
    • B Boaz V

      Hi, in my program, at the constructor of the main driver class, it loads about 6 DLLs (managed) using the Assembly.LoadFile method and then invoking the needed methods using reflections functions. Anyway, when i want to quit the program, sometimes some of the dlls can not be accessed since "they are in use by another program". I've checked the Windows Task Manager and my process do not appear there... any ideas guys? i thought maybe using Dispose procedure or a destructor. can anyone help me with deciding which road to take? and how? 10x

      K Offline
      K Offline
      KevinMac
      wrote on last edited by
      #2

      Don't know if this will help but I have started taking advantage of the "Using" keyword to automatically fire the dispose method. The feature is specific to C# as far as I know. You have to be sure the type you are using implements the IDisposable or it will throw a compile time error. public void YourMethod() { using(MyObj m = new MyObj()) { MyObj.DoWhatYouWant() // Dispose() is called automatically for you when the // Using block exits } } Good luck and I hope it helps.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups