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


Feedback

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

Halloween Costume Ideas 2009 8/10/2009 9:53 AM | halloween

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

i think it is great 8/12/2009 8:56 AM | ed hardy shoes

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

think it is great 9/12/2009 11:29 PM | auto insurance quotes

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

Now at runtime everything works great! 9/22/2009 2:48 AM | Tiffany Bracelets

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

Hi, just wanted to say a BIG thanks! I hit this problem when I updated my 2.0 project to 3.5, your fixed worked in seconds =)
10/24/2009 1:58 PM | John Doherty

Post a comment





 

News


Welcome to my blog.
Here's what we've got on the menu today:

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Syndication: