Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Finding the assemblies loaded in the current AppDomain

1.44/5 (2 votes)
14 May 2012CPOL2 min read 10.1K  
Finding assemblies loaded in the current AppDomain.

Introduction

Finding the assemblies loaded in the current AppDomain.

Explanation

Today I am going to show you a problem solving issue. We normally create separate assemblies (i.e, DLLs) and reference them to the main application. In this process the most common issue is we have coded a logic in our DLL but it is not applied/running through the main application… as many people ask me how to fix this issue, I decided to post this solution… The issue is simple and the cause of the issue may be two reasons: 

  1. Your DLL may not be updated in your main application. 
  2. You may code in one location and refer from another location in your main application.

These two are most common issues, the first will be raised if you are manually copying the DLL from the bin folder of your component project to your main application bin folder. If you do this, every time you change your component you need to repeat this process. If you forget to update, the above issue will occur. A better option is, while adding the reference to your component select the component project instead of selecting the DLL in your bin folder. This will automatically update your component DLL in your main application’s bin folder whenever a change is done. This way we can fix the first cause of the issue.

Image 1

The second cause is straightforward and most people suffer from this issue. To fix this issue we need to know from where the respective component is picked by the CLR. We can do this using the Modules window in Visual Studio 2010. To open this window, go to Debug->Windows->Modules as shown below.

Note: This will be visible while running the application.

Image 2

Now you will see the below window with grid of Assemblies loaded

Image 3

In this window, you can find all the information regarding your component: from where it is loaded and etc.. Using this we can fix another issue too as many people cannot debug their components in the main application. The reason for this is your main application doesn’t have the respective components symbol file, i.e.., .pdb file and in this modules window, you can find if the CLR picks its symbol file or not. If not just copy the latest one to your main application’s bin folder and build and restart the application. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)