I had an error that was been driving me up the wall, CS0234: The type or namespace name 'Pkcs' does not exist in the namespace 'System.Security.Cryptography'. This always happened while developing a web application in Visual Studio 2005 and wanting to use code that deals with certificates. During development Intellisense would find the System.Security.Cryptography.Pkcs namespace just fine. But it couldn't be found at runtime. I had registered the System.Security assembly, and the project always built just fine. The resulting assembly seemed perfectly normal. But no matter what I tried, even reinstalling the .NET framework on the machine, would make that dumb error go away.
Well, after more tinkering I found out the issue is all in the web.config. If you (1) install the normal payware version of Visual Studio 2005 and then (2) Install Visual Web Developer Express 2005 then later as you go back and develop with the payware version of Visual Studio then when you register assemblies it does not always add the references in the web.config file! So the fix in my case was to change the <compilation> element in the web.config, found under <system.web>:
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
I just modified it to include the assembly reference like this:
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
Now at runtime everything works great!