Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Old DLL file keeps being used

Tags:

dll

I have a seemingly random problem where my project will run using an old version of a DLL file that no longer exists. Sometimes the real version of the DLL file will be used, other times an ancient version of the DLL file will be used. Who knows where Visual Studio is getting this DLL file from - it's months out of date!

I know that it is using the old DLL file, because when the application runs I start getting weird 'TypeLoadExceptions', complaining that methods don't exist or don't have implementations.

The following actions will sometimes help, sometimes not:

  • Restarting Visual Studio
  • Restarting the computer
  • Cleaning and rebuilding the solution
  • Deleting everything in \WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
  • Searching for and deleting instances of the DLL file in \Documents and Settings\username\Local Settings\Temp

Sometimes I perform all of the above steps, and it still uses an old copy of the DLL file. Where is it hiding it?!

The same issue exists on our TeamCity server which is using MSBuild. When TeamCity tries to run unit tests it uses an old DLL file.

Now, I know that I can use assembly redirection in the web.config file, but the version number of the DLL file hasn't changed (I don't bother to update it, so it just stays at version 1). I don't want to have to start versioning the DLL files just to solve this problem. I would just like to know which particular caches I need to clear so that I can get on with developing.

like image 743
cbp Avatar asked Apr 07 '11 02:04

cbp


People also ask

Is DLL files com a virus?

DLL Files From DLL Download Sites May Be Infected With Viruses. Since DLL download sites aren't approved sources for DLL files and often have little if any contact information available, there's no guarantee that the file you just downloaded is free from a virus infection.

How do I clear DLL cache?

The SysInternals "cacheset" command can manipulate the file system cache, but the only reliable way to flush it is to reboot. Also, if any application has loaded a DLL into memory, the operating system can reuse those pages without loading from disk.


2 Answers

It hides it in the GAC. There it may reside indefinitely. Using a more recent version may indeed solve the problem, but there is an outstanding bug in Visual Studio that has to do with choosing the correct version of DLL files. (If DLL Hell wasn't bad enough, the Visual Studio team is making it worse!)

Finding it in the GAC is tricky, and I cannot advise you on how to do that, but once the old version is deleted from there, it will not be found again. Sometimes, even though you are pointing the compiler at a newer version (by date), it will use the older version, because it has the same version level (by version). That is its bug.

like image 192
shipr Avatar answered Sep 22 '22 05:09

shipr


Who knows where Visual Studio is getting this dll from - it's months out of date!

The Modules Window is your friend...

It'll tell you exactly where that file is coming from. You can even use it with arbitrary processes if you attach the debugger.

like image 31
Eric Nicholson Avatar answered Sep 18 '22 05:09

Eric Nicholson