Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Visual Studio adding assemblies to my web.config?

Tags:

Every time i build, or publish, a web-site, Visual Studio attempts to check out the web.config file so that it can add numerous assemblies that are not required.

In other words:

web.config before:

<configuration>    <system.web>       <compilation>          <assemblies>          </assemblies>       </compilation>    </system.web> </configuration> 

web.config after:

<configuration>    <system.web>       <compilation>          <assemblies>              <add assembly="Microsoft.ReportViewer.Common... />              <add assembly="Microsoft.ReportViewer.WinForms... />              <add assembly="System.DirectoryServices... />              <add assembly="System.Windows.Forms... />              <add assembly="ADODB... />              <add assembly="System.Management... />              <add assembly="System.Data.OracleClient... />              <add assembly="Microsoft.Build.Utilities... />              <add assembly="Microsoft.ReportViewer.ProcessingObjectModel... />              <add assembly="System.Design... />              <add assembly="Microsoft.Build.Framework... />          </assemblies>       </compilation>    </system.web> </configuration> 

None of these assemblies are required, and most don't exist on the target test, or production, servers.

i keep deleting them every time i build, but it's getting real annoying real fast.

Right now my workaround is to leave web.config read-only - so Visual Studio cannot add assemblies to it.


Update

Screenshots as proof:

Project Property Pages before:

link text

Web.Config before:

alt text

Project Property Pages after:

alt text

Web.config after:

alt text

Update Two

It should be pointed out explicitly that the web-site works without these extraneous references being added. My interim solution is to keep web.config read-only, and hit Cancel whenever Visual Studio complains that it's read-only as it tries to modify it. If i can just stop Visual Studio from trying to modify it in the first place...


Update Three

It looks like it's not possible. Someone can feel free to give the correct answer, "You cannot stop Visual Studio from adding assemblies to your web.config." and i'll mark it.

The only reason i'm keeping the question up is that hopefully someone knows the super-secret option, or registry key, or project or solution setting, to tell Visual Studio to stop thinking.


Update Four

i didn't accept the accepted answer, and i'd unaccept it if i could. i'm still hoping for the panacea. But right now i'm leaning towards:

  • Answer: cannot be done (manu08)
  • Workaround: filtered GAC assemblies registry key (Nebakanezer)

How do i stop Visual Studio from adding assemblies to my web.config?

References

  • ASP Net - Visual Studio keeps adding Oracle assemblies to web.config
  • Why are the Visual Studio Add-In Assemblies being added to my web.config?
  • Visual Studio Adds Assembly Reference To web.config
  • removing VsWebSite.Interop Assembly from Web.Config
  • Visual Studio 2005 automatically adding references to web.config on build
like image 498
Ian Boyd Avatar asked Sep 09 '09 20:09

Ian Boyd


People also ask

Where is Web config file in Visual Studio 2022?

config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder.

What is Web config in Visual Studio?

The web. config is a file that is read by IIS and the ASP.NET Core Module to configure an app hosted with IIS.


1 Answers

Maybe the "Avatar DotNet Library" is referencing those assemblies by itself. The references of a referenced assembly are needed to correctly deploy a project. Otherwise, how could the referenced assembly work?

Note that it's possible that your referenced assembly does not use its own references, although they exists.

Edit: You can use the great tool ".Net Reflector" to check this.

like image 169
Juan Calero Avatar answered Oct 05 '22 13:10

Juan Calero