What is a dll.refresh file in ASP.Net?

asp.net

asp.net Problem Overview


In our ASP.Net web project we seem to have some .refresh files associated with some of the 3rd party Dlls we're using. Any idea what they are and how/when they are created?

asp.net Solutions


Solution 1 - asp.net

These files give the path to the DLL in question to tell Visual Studio where to find it (you can check this if you open them in a text editor). They will be created each time you add a new reference to the project.

They normally appear when you are using a project type that does not create a standard Visual Studio project file, as normally paths to referenced DLLs would go in there.

Solution 2 - asp.net

From here:

>In an ASP.NET project, adding a file-based reference will add a .refresh file in the Bin folder. When the project is under source control, this file is then added to source control. *.dll.refresh files that litter the bin directory. Every time you add an external reference, you'll find a dll.refresh file right next to it. These dll.refresh files are an exception to the rule, and they should go into source control. Its the only way your web project will know where its references live.

Solution 3 - asp.net

Some information about the refresh files after trial and error. These experiments were done with Visual Studio 2012. The references were added to a C# asp.net web project.

As was discussed, adding a reference to an assembly through browse adds a .refresh file. However, if there are additional dependent DLL's on the explicitly added DLL in the directory that you add from, the dependents are implicitly added as well, but without .refresh files! So for example, I add a reference to "MyAssembly.dll" I will get also "MyAssembly.dll.refresh". But if there is an assembly "MyDependentAssembly.dll" that "MyAssembly.dll" depends on I will not get a "MyDependentAssembly.dll.refresh". So what happens is that the one assembly is refreshed but not its dependents! You must add the DLLs one at a time in reverse order of dependency and then things will work better.

Some other things to be careful of. Adding "MyAssembly.dll" will also add "MyAssembly.pdb" if it is present. Also "MyAssembly.xml" will be added to the references if it is present. Those two files will refresh too when "MyAssembly.dll.refresh" is present.

But, when does Visual Studio decide to look for refresh files? Now remember, in a web project, the project file does not keep track of referenced DLL's specifically. You will not find the DLL's listed in the project file only project dependencies. So when does the refresh happen?

The answer to when refresh happens is during a build when the referenced assembly has to be loaded. That means, though that building a prebuilt updateable website may not grab all of the DLLs. I kept having a DLL that would not refresh and then I realized it was being used only inside of a .ascx file. Unchecking the "Allow precompiled site to be updateable" checkbox in the MSBuild Options project page fixed that problem for me.

Still if you add referenced DLLs that are loaded through reflection in your code, they will not be updated through a reference. You will have to use build events to copy them into the bin directory.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJackson PopeView Question on Stackoverflow
Solution 1 - asp.netHullCitySteveView Answer on Stackoverflow
Solution 2 - asp.netSharpUrBrainView Answer on Stackoverflow
Solution 3 - asp.netJack D MenendezView Answer on Stackoverflow