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!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# 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'

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

# rny one got reply here plz

Even iam looking for the same informatiom 12/17/2009 12:48 AM | buy lasix online

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

Thank u really to think this write up is a 'good bit' i apreciate that from you... 1/12/2010 3:01 AM | Cheap Lasix

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

Thank you! Thank you! Thank you! 1/25/2010 3:20 PM | Marc

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

It is great to see. Thanks for such great post. 1/29/2010 5:10 AM | Accounting Services

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

http://www.abercrombie4sale.com
Thank you for sharing. 2/25/2010 9:08 PM | letty

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

Thank you for sharing. 2/25/2010 9:09 PM | letty

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

Excellent post, thank you very much for taking the time to share with those who are starting on the subject. Greetings
3/4/2010 7:31 AM | Biletul Zilei

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

Excellent blog post. 3/6/2010 8:19 PM | bike games

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: