The type or namespace name 'Pkcs' does not exist in the namespace 'System.Security.Cryptography'

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 element in the web.config, found under <system.web>:

<compilation debug="true"> 

I just modified it to include the assembly reference like this:

<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!

This article is part of the GWB Archives. Original Author: Lorin Thwaits

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.