How do references work in ASP.NET WebForms website

2020-07-18 05:04发布

问题:

I have taken over an old ASP.NET website (as opposed to a web application) and I am having problems getting it to build in our CI environment due to an unresolved reference to the Ajax Control Toolkit.

I see the same error on my local development machine, and can fix it by manually adding a reference to AjaxControlToolkit.dll (the project's NuGet packages.config file references the Ajax Control Toolkit).

However, ASP.NET websites do not have a .csproj file (unlike web applications), so making this change doesn't seems to update any file in the source code tree.

When I build the website in Visual Studio I can see it copying a large number of other dlls into the website's Bin folder. All apart from AjaxControlToolkit.dll...

So my question is basic: How do ASP.NET WebForm websites manage their references?

回答1:

Asp.Net website has a folder Bin. In this folder all references are placed you just need to copy and paste dll files into Bin folder.



回答2:

My understanding of the system is that ASP.Net handles references in several different ways:

Referenced projects are stored in the "solution" file typically in the main directory, if you edit the file in notepad you should see references in the following format:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActiveDirectoryHelper", "..\..\DataAccess\ActiveDirectoryHelper\ActiveDirectoryHelper.csproj", "{D1DDF7A2-6F69-4400-92A7-FD7F4CD87FE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XXX.Library", "..\..\DataAccess\XXXLibrary\XXX.Library.csproj", "{F0A396FA-4588-41E8-B072-7121501689FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\..\DataAccess\Common\Common.csproj", "{F80C48D8-F6AD-43A2-8AB0-7E4A8461D372}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "..\..\DataAccess\DataAccess\DataAccess.csproj", "{F9AEC8CE-6E04-4848-8168-1436EBA4E734}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess.Tests", "..\..\DataAccess\DataAccessTests\DataAccess.Tests.csproj", "{472C68E1-66AA-486D-9B76-BC72254BB0F9}"

Third party "DLL's", these are stored by including a "refresh" file in the "Bin" directory. If your using source control of any type don't forget to check these files in:

(TFS Example)

If you open the "refresh" file you will see something like the following:

Library\AjaxControlToolkit.dll

NuGet I think is a bit more compiled see the details listed here for a strategy on how to approach this.

Standard and third party library's, are also mentioned in the "web.config" file, I assume this is how they are referenced:

<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

None of this I've ever seen official documentation on, all of it I've derived from my struggles with TFS or Visual Studio over the years, I wish there was something official written up on this that people could reference. Microsoft's official documentation has a tendency to glaze over important details such as these, and when stuff breaks your left playing detective with undocumented low level implementation details...



标签: asp.net web