Assembly location in ASP.NET
An interesting note that I've found while updating the ConfigEx library: the assembly DLL file in the ASP.NET application might be located in a place different from what we expect. During runtime, it is actually not in the place where the 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.
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 get the original location of the web application, we should use the Assembly.GetName().CodeBase
property.
next post: Reading large XML files
previous post: WPF Async Pack 1.0