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. Reflection Problems...

Reflection Problems...

Scheduled Pinned Locked Moved C#
questioncsharpdebugginghelptutorial
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.
  • N Offline
    N Offline
    Norman Timo
    wrote on last edited by
    #1

    Hello everybody! First I´m sorry about my english, I come from germany. I have a little obscure problem with reflection. I created a own class with only one constructor -> private static System.Reflection.Assembly assembly; public MyReflection(string dllfilename) { assembly = System.Reflection.Assembly.LoadFrom(dllfilename); //** // do something with assembly (this part works fine!) } In my main application I´m creating an object from this class like: MyReflection myRefl = new MyReflection(dllfilename); I choosed that a user can change the assembly file (for example to actualize it) in my main application and the code line "MyReflection ... = new ..." is recalled with the different dllfilename. If I debug MyReflection class it is working fine until the line signed with //**. I can recrate the object how many times I want, but it keeps the first assembly file. Why? Why doesn´t actualize my computer this file (the string "dllfilename" is always appearing correctly!) Is it a problem with the garbage collector? And if this is true, how can I definetely force that C# destroys an object? It would be nice if someone is answering to me.. Ciao Norman-Timo

    N 1 Reply Last reply
    0
    • N Norman Timo

      Hello everybody! First I´m sorry about my english, I come from germany. I have a little obscure problem with reflection. I created a own class with only one constructor -> private static System.Reflection.Assembly assembly; public MyReflection(string dllfilename) { assembly = System.Reflection.Assembly.LoadFrom(dllfilename); //** // do something with assembly (this part works fine!) } In my main application I´m creating an object from this class like: MyReflection myRefl = new MyReflection(dllfilename); I choosed that a user can change the assembly file (for example to actualize it) in my main application and the code line "MyReflection ... = new ..." is recalled with the different dllfilename. If I debug MyReflection class it is working fine until the line signed with //**. I can recrate the object how many times I want, but it keeps the first assembly file. Why? Why doesn´t actualize my computer this file (the string "dllfilename" is always appearing correctly!) Is it a problem with the garbage collector? And if this is true, how can I definetely force that C# destroys an object? It would be nice if someone is answering to me.. Ciao Norman-Timo

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Are you trying to load a different version of the same assembly? If so, if you havn't strong named the assmebly the CLR class loader will disregard the version number of the assembly. To perform this operation safely so you don't have to deal with file locking, take a look at AppDomain.ShadowCopyFiles as this is implemented by fusion and also used in ASP.NET. At least load the assembly into it's own AppDomain which will allow you to safely unload the AppDomain when you are done with the assembly. - Nick Parker
      My Blog | My Articles

      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