Assembly location in ASP.NET

Just and interesting note that I’ve found while updating the ConfigEx library: the assembly DLL file in ASP.NET application might be located in place different from what we expect. During runtime it is actually not in the place where application is hosted.

If we check the Assembly.Location value, we will see the path similar to

C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\root\faae9399\e8a24a5f\assembly\dl3\5725e394\474bcfba_aa4dd201\MyWebApp.dll

This is because Microsoft uses the Shadow Copying Assemblies mechanism.

But in some cases we still might need to access the original assembly file, or look for some files in the same location – where we actually hosted the application.

In order to find out it, we should use the Assembly.GetName().CodeBase property instead.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s