Click here to Skip to main content
15,892,768 members
Articles / Programming Languages / C#
Tip/Trick

Finding the assemblies loaded in the current AppDomain

Rate me:
Please Sign up or sign in to vote.
1.44/5 (2 votes)
14 May 2012CPOL2 min read 9.9K   5   1
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)


Written By
Architect
India India
I work as a Technical Architect at one of the leading US-based Organization., I am passionate to learn new thing and love to share my observations and learnings via. articles.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Mlsoun14-May-12 19:42
Mlsoun14-May-12 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.