This article is a mirror article of machine translation, please click here to jump to the original article.

View: 46998|Reply: 2

[Source] .NET does not get the full reference assembly assembly

[Copy link]
Posted on 8/22/2020 10:41:02 AM | | | |
Use. .NET to get the loaded assembly is incomplete, although we refer to other libraries, but without calling, it cannot be obtained in the loaded assembly, this article shares to get the complete assembly assembly in WinForm and ASP.NET.

introduction

Use. .NET to get the loaded assembly is incomplete, although we refer to other libraries, but without calling, it cannot be obtained in the loaded assembly, this article shares to get the complete assembly assembly in WinForm and ASP.NET.

ASP.NET (unmeasured)

The .NET Framework defers loading assemblies into the current AppDomain until they are needed. For example, if you only call a third-party library from SomeMethod(), the third-party DLL will usually not be loaded until the first run of SomeMethod().

AppDomain.GetAssemblies() gives you all the assemblies that have been loaded into the current AppDomain. BuildManager.GetReferencedAssemblies() returns a list of all assemblies referenced from Web.config and other locations, and loads those assemblies into the current AppDomain.

Code:



WinForm

Start by using the code below to get the loaded assembly.



The number of Assembly assemblies obtained is 12, as shown in the following figure:



When we don't call the methods of other libraries, the main application does not load its dlls, probably to save performance overhead, so the first time we call the methods of other libraries, it may be a little slower.

Use the modified code, as follows:





The number of assembly assemblies obtained is 117, and the principle is to get the dll under the application directory and load it.

In this case, when calling AppDomain.CurrentDomain.GetAssemblies(). ToList() method, you can get the complete assembly, which may be more than 117.

Get the current assembly





Previous:.NET uses Redis cache for expiration notifications
Next:Professional management tool for ServiceNow cloud IT business
 Landlord| Posted on 12/25/2020 3:50:46 PM |
Posted on 9/22/2021 8:39:35 PM |
Learn to learn...
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com