How do I unload a dll using c#. Basically what I want to is test if a certain dll has been loaded if it has then I want to remove it from memory. The reason is that I want to overwrite the dll file but I can't overwrite it since the dll is being used. The dll that I am trying to unload is written in probably c or c++ so it is unmanaged code.