Geeks With Blogs
Chris Falter .NET Design and Best Practices

In previous versions, ASP.NET considered the web.config file to be untouchable.  What you, the developer, wrote into the file may as well have been engraved like the Ten Commandments into stone tablets.  But under the new compilation model, ASP.NET wants to collaborate with you in authoring the web.config file.  Specifically, during site compilation, it will insert lines into the /configuration/system.web/compilation/assemblies element to make sure that the runtime JIT compiler knows how to link to the dependencies of project references.  In other words, it will enumerate the entire dependency tree and write the necessary metadata to make sure that the JIT compiler knows what it needs, if you have not already provided the information via an explicit reference.

We stumbled onto this behavior quite by accident.  For no obvious reason, when we ran our build script to compile/deploy a new website, the Visual Studio 2005 compiler decided to sneak these lines into the web.config:

<add assembly="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<
add assembly="Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<
add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

And VS 2005 was quite insistent about adding these lines: it actually removed the read-only attribute from web.config, inserted the lines, and continued on its merry way.  We, of course, knew nothing about the compiler's silent literary ambitions, so the site deployed as usual.  But then it blew up; we did not have the stdole and Office assemblies version 7.0.3300.0 installed on the web farm, so things went south very quickly.  The event log recorded something like this:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Googling turned up a thread where a developer declared that the problem could be solved by changing the default html editor on the build machine.  This did not work for us.  Then I noticed that one of my colleagues had recently added a new reference in one of the projects that was in the site project reference list.  In other words, after my colleague's modification, we could now draw a line indirectly from the site to the stdole and Office assemblies: (1) site references a project, (2) the project references the Dart.PowerWEB.LiveControls component, and (3) Dart.PowerWEB.LiveControls references the stdole and Office assemblies.

We had not noticed this prior to deployment because the Dart development suite had installed the assemblies on the test sites' host server.  Of course, the Dart run-time environment on the production server farm did NOT install the assemblies.  Shame on you, Dart!  After we removed the Dart.PowerWEB.LiveControls reference from the project, ASP.NET lost its literary ambitions.  And not a moment too soon; next thing you know, the compiler will start a blog.  And I don't want to have to compete with Microsoft technology!

So if you notice the new literary ambitions of the ASP.NET compiler, and they suddenly mess with your deployment, you know what to do: examine any references you recently added to the site's dependency tree, because one of them is the source of your problem.  Keep removing references until ASP.NET ends its crazy literary ambitions.  There are enough authors and bloggers in the world already; we don't need ASP.NET to join the crowd.

Posted on Friday, April 28, 2006 8:39 PM .NET Gotchas | Back to top


Comments on this post: The Literary Ambitions of the ASP.NET 2.0 Site Compiler

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
found this post via google and it helped me to figure out how to get visual studio to quit adding the stdole reference to my web.config -- thanks! i just removed the other projects from the web solution and added references to the DLLs the projects build to instead. what i don't understand is where studio gets the idea that anything is actually using stdole, since it works great with that reference deleted from web.config...
Left by misterhaan on May 18, 2006 7:24 PM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
Found this article via http://www.thescripts.com/forum/thread465826.html / Google

YOU SAVED MY DAY! Thanks!
Left by Anonymous on Dec 22, 2006 1:16 PM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
We've experienced exactly the same issue in our team, and came across this blog when looking for a solution, but we didn't have the option of removing the offending references from our solution (why would you include references to assemblies you're not actually using)?

Take the example where you have a solution containing one web project and you need to reference some external assembly. We noticed that if you directly add a file reference from the web project, the reference in the web.config is only 'shallow' (ie only the single assembly gets added to the web.config). No problem there.

However, say you have a second project in your solution (a class library for example), and there's a project dependency from your web project to your class library project. If you add a reference to the external assembly from the class library project, your web.config suddenly gets filled with 'deep' references as the IDE attempts to unpick every dependency in the chain (those 'literary ambitions you were talking about)!

We discovered that this behaviour is because the 'Specific Version' property of the external file reference is 'True' by default; changing it to 'False' prevents VS2005 probing the external assembly's manifest and enumerating all of its dependencies in your web project.
Left by Matt Salmon on Feb 02, 2007 10:19 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
Matt,

Thanks for dropping by and offering the insight! To summarize what you're saying, the compiler will enumerate the dependency tree in web.config under the following circumstance:

1. Web project has a project reference to ClassLibraryProject1
2. ClassLibraryProject1 has a file reference to Library2.dll, and the file reference "Specific Version" property is set to "True."

Thus, if you cannot simply remove the file reference (ours was superfluous, but I can understand why not all can be removed), then you can simply set the "Specific Version" property of the file reference to False.

Incidentally, I just googled "Specific Version" and "file reference" for site:microsoft.com and found nothing relevant. Microsoft has never documented this behavior. At the same time, having just installed VS2005 sp1, I added a file reference and discovered that the Specific Version property had been set to FALSE by default. I wonder if sp1 changed the default setting? Perhaps some customers had made support calls, so Microsoft introduced the change in sp1 to help us, but for some reason they never saw fit to publish a KB article.
Left by Chris Falter on Feb 02, 2007 2:16 PM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
BTW, I suspect that developers of Winforms (Windows Forms) and console applications will find that the compiler will enumerate dependencies in app.config in the same way. And presumably, setting the Specific Version property to False in a class library (to which the main project has a project reference) will resolve the problem.
Left by Chris Falter on Feb 02, 2007 2:25 PM

# ASP.NET 2.0:1, Bil:0
Requesting Gravatar...
I just spent the better part of the evening chasing down the dumbest error I've ever seen. ASP.NET decided
Left by Fear and Loathing on Feb 20, 2007 12:54 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
very nice, thank you!
Left by cobalt on Apr 06, 2007 10:47 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
I have no idea what reference is causing this. I'm using a generated nettiers data layer and haven't added any references. I did a global search for "Specific Version" and found nothing. Although I was able to deploy by manually removing useless assembly references, could someone point me in the right direction to set the "Specific Version" attribute? Thx.
Left by Jimi on Jun 11, 2007 6:33 AM

# Isolating Web Settings from Sub-Applications using InheritInChildApplications
Requesting Gravatar...
A while back, Steve Smith brought up a recurring problem I think most of us have bumped into, which is
Left by J. Ambrose Little on Jun 20, 2007 3:07 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
Thanks for the info!
Left by Jack Nichols on Feb 22, 2008 5:10 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
Hi FYI I had the same thing (the office assembly reference being added automatically by VS2005) after installing Sharepoint Designer 2007 on my system. It seems to have caused the Excel 2000 interop assembly to have a new reference to this "office" thing, which doesn't exist on the server (one solution would probably have been to install sharepoint designer on the server...:)

So if I may add to Chris' great post above: as well as thinking of references added to your project, also think about whether you've installed any software recently on your dev system -> it may have cause your existing .NET assemblies to grow a new reference..........??
Left by Mike M on Jul 27, 2009 7:55 AM

# re: The Literary Ambitions of the ASP.NET 2.0 Site Compiler
Requesting Gravatar...
Really this is very useful article, it helped me alot
Many Thanks
Left by Mohamed Kamal Aboelmagd on Nov 22, 2010 1:21 PM

Your comment:
 (will show your gravatar)


Copyright © Chris Falter | Powered by: GeeksWithBlogs.net