Answered by:
Can I remove some of the .DLL's?

Question
-
User-900017823 posted
An old ASP.NET WebForms app I maintain, has several .DLL's in the bin folder. I'm thinking that I can probably remove some of them without any negative side effects. The References tab, besides having reference name and version numbers, has a column labeled Type. There are 3 distinct types: GAC, BIN and Project. GAC is obvious. I'm guessing that Project means that the project I'm reviewing references one of the other 11 projects in this Visual Studio solution.
The one type the interests me the most is the last one, which is labeled BIN. Am I correct in thinking that any reference with a type of BIN is a .DLL? If so, if I can find some other way of referencing those .DLL files, I would hope I could get rid of them in this project, correct?
Monday, March 30, 2020 8:15 PM
Answers
-
User409696431 posted
Go to https://imgur.com/a/JmHya29 (which is the link you used and is clearly not the URL of an image) and right click on the image and select View Image. You will then be on a page https://i.imgur.com/Pmw5le1.jpg which is the link to an image file.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, April 1, 2020 11:17 PM
All replies
-
User415553908 posted
It is a bit hard to tell without knowing your application, but i would say, DLLs in Bin folder are there for a reason - you might be able to tell which ones your application references, but these references will likely have their own references too.
You definitely can load DLLs dynamically, but it's completely different experience and you will likely encounter heaps of maintenance pain should you choose this path.
Tuesday, March 31, 2020 2:54 AM -
User-1330468790 posted
Hi DoctorWho,
I understand that what you need should be How the Runtime Locates Assemblies
In the above link, you will find that the runtime uses 4 steps to resolve an assembly reference
- Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file. If the configuration file is located on a remote machine, the runtime must locate and download the application configuration file first.
- Checks whether the assembly name has been bound to before and, if so, uses the previously loaded assembly. If a previous request to load the assembly failed, the request is failed immediately without attempting to load the assembly.
- Checks the global assembly cache. If the assembly is found there, the runtime uses this assembly.
-
Probes for the assembly using the following steps:
-
If configuration and publisher policy do not affect the original reference and if the bind request was created using the Assembly.LoadFrom method, the runtime checks for location hints.
-
If a codebase is found in the configuration files, the runtime checks only this location. If this probe fails, the runtime determines that the binding request failed and no other probing occurs.
-
Probes for the assembly using the heuristics described in the probing section. If the assembly is not found after probing, the runtime requests the Windows Installer to provide the assembly. This acts as an install-on-demand feature.
-
DoctorWho
The References tab, besides having reference name and version numbers, has a column labeled Type. There are 3 distinct types: GAC, BIN and ProjectI can not find the Type column for reference so that I can not provide you with information about it. Could you please share/post screenshot about that?
However, from my best guess, the 'project' type might represent Project-to-project references which means references to projects that contain assemblies. When you have a project that produces an assembly, you could reference the project and not use a file reference.
DoctorWho
The one type the interests me the most is the last one, which is labeled BIN. Am I correct in thinking that any reference with a type of BIN is a .DLL? If so, if I can find some other way of referencing those .DLL files, I would hope I could get rid of them in this project, correct?Regarding the type 'BIN', it should be a file reference to .DLL file, like GAC.
From my view, if you could make modifications on the references, you could remove the .DLL files.
During the process, you should be always aware of the compatibility between the .NET framework and the assembly.
Hope this can help you.
Best regards,
Sean
Tuesday, March 31, 2020 5:19 AM -
-
User475983607 posted
Dropping a DLL in a web application's bin folder is the same as creating a reference. Can you explain the reason for removing DLLs from the bin folder?
Tuesday, March 31, 2020 2:25 PM -
User753101303 posted
Hi, no image. Try the "insert/edit image" button an a direct link rather than what seems an embed snippet.
Or if you suspect a DLL is not used any more, remove it and see what happens when recompiling. Preferably use a source code control software or do a backup first.
Tuesday, March 31, 2020 2:39 PM -
User-900017823 posted
The reason why I'd like to remove the .DLL's from the bin folder, is because the original developer copied .DLLs from various projects into the bin folder. This made lots of the application a black box to me, since I didn't know what he was doing and why/how anything worked. Let me give you an example.
Most of the DLLs the original developer used were all written here, many years ago by people who've long since left. One of these DLLs had a method that was passed a number, but what in heck was that for? No explanation, no hint in Visual Studio because whoever wrote the DLL never bothered to use the Summary feature available in Visual Studio for decorating a method call with a comment so the developer can put in which show up Visual Studio for other developers to see. Anyway, it took me a few weeks to find the code. I eventually did, so I could see what was going on. Whoever wrote that had it accept an integer that would write to the .HTML file carriage return/linefeed combinations, the number of combinations depended upon the number passed to that DLL's method. They didn't use HTML break (<br>) strings, they used carriage return/linefeeds combined together! Whoever the author was for that probably had a background in writing DOS applications. That worked, 15 or more years ago when it was originally written and everyone had the same monitor. But it wasn't working when I had to take it over. What was happening is the monitors people were using today didn't bring the hyperlinks far enough down from an image. Half of the hyperlinks were behind the image, so users couldn't interact with them as they needed to. Once I had the code I got rid of the carriage return/linefeed nonsense and put in proper positioning with divs and so on.
Anyway, that experience showed me that if the DLL was written in house, I want to have the code in the VS solution, rather than just a DLL.
Tuesday, March 31, 2020 2:54 PM -
User475983607 posted
You did not really answer the question. You did manage to throw previous developers under the bus though. Keep in mind that browser do not display white space characters like control and line feed. However, wrapping method results in HTML can potentially mess up another applications if the DLL is shared.
Anyway, that experience showed me that if the DLL was written in house, I want to have the code in the VS solution, rather than just a DLL.Again, DLLs are shared libraries. The DLLs may or may not be in the same solution as a web project. This is very common situation if your organization supports many web applications and the web applications share common DLLs.
You can't just remove a DLL if the web application is using the DLL. The application will throw an exception. You'll need to find the DLL source code and rewrite code or move the code to the web application.
Tuesday, March 31, 2020 3:27 PM -
User-900017823 posted
Here's another try to get the image into a post
Tuesday, March 31, 2020 4:54 PM -
User-900017823 posted
Well, that didn't work either. Every time Ive trid to post a link using the "Insert/edit image" button on this website, it have never worked for me.
Tuesday, March 31, 2020 4:55 PM -
User475983607 posted
DoctorWho
Well, that didn't work either. Every time Ive trid to post a link using the "Insert/edit image" button on this website, it have never worked for me.
Host the image then you can hot link to the image. This forum does not allow uploading images.
I'm pretty sure the image will not help anyway. The community has no way to verify DLLs copied to the bin folder are in use.
Tuesday, March 31, 2020 5:02 PM -
User409696431 posted
Here's your first image, done correctly. When you link to an image, link to the actual image, not the imgur landing page for it. Use the View Image function to get the link to the actual image.
Mind you, that doesn't change the answer that you can't simply remove DLLs unless you know for a fact that they are no longer used. As pointed out, if you want to put them in your code instead, you need to have the source.
You've shown one case where you found a bug in an old DLL, but you solved it by, as one would expect, finding the code and modifying it.
Tuesday, March 31, 2020 11:41 PM -
User753101303 posted
Are they shared between multiple projects? If not it can make sense to reference the project instead (which will build the DLL used from the main project) to keep the source code handy.
if not you shoud likely rather look at using a source code control product such as GitHub or Azure DevOps to manage the code for all those projects. DLLs could be built as nuget packages and published privately to be consumed by other projects.
Wednesday, April 1, 2020 12:49 PM -
User-900017823 posted
Kathy, when I tried putting in the link to the image I put on Imgur, I thought I was sharing the image, not the page it is on. You've shown me that I didn't do it correctly, but I still have no idea how to get the link directly from Imgur.
Wednesday, April 1, 2020 1:48 PM -
User-900017823 posted
Are they shared between multiple projects? If not it can make sense to reference the project instead (which will build the DLL used from the main project) to keep the source code handy.
if not you shoud likely rather look at using a source code control product such as GitHub or Azure DevOps to manage the code for all those projects. DLLs could be built as nuget packages and published privately to be consumed by other projects.
Very good questions. This ASP.NET app in Visual Studio has 12 projects. I've often thought that it is way too complicated for what the app actually does. My guess is the original developer would put in a project, just to run 1 method out of 1 class in the project. I've never mapped the interrelationships between all of these projects, their dependencies, etc. Perhaps when I have some free time I can do that. As to other applications using some or all of the 11 DLL projects, I know they're being used elsewhere. I've no idea how many other apps use them.
Wednesday, April 1, 2020 1:55 PM -
User409696431 posted
Go to https://imgur.com/a/JmHya29 (which is the link you used and is clearly not the URL of an image) and right click on the image and select View Image. You will then be on a page https://i.imgur.com/Pmw5le1.jpg which is the link to an image file.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, April 1, 2020 11:17 PM -
User-900017823 posted
Go to https://imgur.com/a/JmHya29 (which is the link you used and is clearly not the URL of an image) and right click on the image and select View Image. You will then be on a page https://i.imgur.com/Pmw5le1.jpg which is the link to an image file.
Thank you very much!!
Thursday, April 2, 2020 2:37 PM