Cryptography block Error - HELP!!

Topics: Cryptography Application Block, Security Application Block
Dec 26, 2009 at 4:21 PM

Ok I am really getting sick and tired of trying to use these various application blocks!! I am at my wits end!

 I am trying to use the Cryptography app block in my Internet ASP.Net web application. I am creating a new VB class library to manage all security related functions for my web application. Therefore I am also going to embed the code I have for salt and hashing of passwords at login into this class library. So at this point all I am trying to do is simply just hash the password keyed into the Login form. In my VB class library solution I added a web application project (for testing) with just one page, a login page, to test out the hashing function and I keep getting the error message shown below. If someone can help me out here, I would really appreciate it!

=====================================================================================================================================================================================

System.Configuration.ConfigurationErrorsException was unhandled by user code
  Message="The configuration section securityCryptographyConfiguration is not defined in the current configuration for the AppDomain."
  Source="Microsoft.Practices.EnterpriseLibrary.Security.Cryptography"
  BareMessage="The configuration section securityCryptographyConfiguration is not defined in the current configuration for the AppDomain."
  Line=0
  StackTrace:
       at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.CryptographyConfigurationView.get_CryptographySettings() in C:\EntLib41Src\Blocks\Security.Cryptography\Src\Cryptography\CryptographyConfigurationView.cs:line 71
       at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.CryptographyConfigurationView.GetHashProviderData(String hashProviderName) in C:\EntLib41Src\Blocks\Security.Cryptography\Src\Cryptography\CryptographyConfigurationView.cs:line 101
       at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashProviderCustomFactory.GetConfiguration(String name, IConfigurationSource configurationSource) in C:\EntLib41Src\Blocks\Security.Cryptography\Src\Cryptography\HashProviderCustomFactory.cs:line 34
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) in C:\EntLib41Src\Blocks\Common\Src\Configuration\ObjectBuilder\AssemblerBasedCustomFactory.cs:line 52
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) in C:\EntLib41Src\Blocks\Common\Src\Configuration\ObjectBuilder\AssemblerBasedCustomFactory.cs:line 82
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context) in C:\EntLib41Src\Blocks\Common\Src\Configuration\ObjectBuilder\Extensions\ConfiguredObjectStrategy.cs:line 57
       at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
  InnerException:

Dec 28, 2009 at 2:42 AM

Let me guess, your securityCryptographyConfiguration config section is in the config of your class library.  Am I right? If this is the case, your config should be in the host project (web application) as class libraries don't own config files.  If you still want to have the cryptography config in the class library, you have to make use of a FileConfigurationSource - http://blogs.msdn.com/tomholl/archive/2006/04/02/entlib2externalconfig.aspx

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 28, 2009 at 3:50 AM

Yes, I do have the config in my class library.

Can you just give me a quick code snippet of what section belongs in the App.Config of my class library and what section belongs in the Web.Config of my web application, please?

Dec 29, 2009 at 3:58 AM

You mean what section should be in the app.config and in the web.config?  All configuration settings are being read from the config of the hosting project and not in the class library.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 30, 2009 at 12:00 AM

So the class library does NOT need any kind of .config file, such as an app.config? I should put everything related to the configuration for the blocks into the web.config of my web application? Is that correct?

Dec 30, 2009 at 1:02 AM
Edited Dec 30, 2009 at 1:07 AM

ok so I now have the security class working. I took out the app.config in the class library and put everything in the web.config of the web application and now the password was hashed as I wanted it to. Thank god and thank you for your help!!