Tutorial :I've read that assemblies manually placed inside Bin are also automatically referenced by



Question:


Q1

We can add assembly reference to a web project via Website --> Add Reference , and assembly will automatically be referenced by all pages in that web project.

But I’ve read somewhere that even if we simply copy ( thus we don’t add it via Website --> Add Reference ) an assembly to the Bin directory of a web project, that it will still be automatically referenced by all pages in that project. But as far as I can tell, that is not the case?!


Q2

A)Deployed web site project also generates PrecompiledApp.config and website1_deploy.wdproy.

Should these two files also be copied to the server?

B) Deployed Web application project also generates WebApplication1.csproj and WebApplication1.csproj.user.

  • Should the two files also be copied to the server? If so, why?

  • I assume obj directory shouldn’t be copied to the Web server?!


thanx


Solution:1

Q1: "add reference" in a web site project means more than just copying the dll to the bin directly. It also means to place a dependency in app.config and to place a hint file which helps Visual Studio to find the dll from the source. This path is used by visual studio to copy the dll back to the bin directly (if somehow it gets removed) and to provide the "update reference" functionality. Having the dll registered in the app.config is essential for the runtime to compile your code using the right version of the dll.

Q2A: website1_deploy.wdproy is not required. PrecompiledApp.config is. This file tells the runtime that the website was already precompiled and that the aspx files are just placeholders for IIS.

Q2B: you don't have to copy all those files. The .csproj file is just for visual studio to keep track of all files in your project. The runtime doesn't do anything with it. The .csproj.user file has your settings, again the runtime doesn't do anything with it. It doesn't even understand it. The obj folder is the temporary directory for the compiler. Also not needed after compilation.


Solution:2

Q1 - copying to bin is a runtime thing. the Web Project is a develop-time thing. They are related but not the same.


Solution:3

when you give a reference, it generally loads the reference in the config file, so if you add the required entry in config file and copy the dll in bin folder, it will be referenced directly without actually "add a reference"

you dont need to copy the wdproj file at all. its simply a deployment project which is helpful to build your releases.

you would need to copy the precompiled.config file to the deployed directory, though.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »