Thursday, September 21, 2006

VS Problem

While doing the transition to VS2005 of a web service, we came across the following exception at runtime:

System.Web.Services.Protocols.SoapHeaderException: Server unavailable, please try later ---> System.Configuration.ConfigurationException: WSE032: There was an error loading the microsoft.web.services2 configuration section. ---> System.Configuration.ConfigurationErrorsException: WSE040: Type xxx.CustomUsernameTokenManager, xxx could not be loaded. Please check the configuration file.
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)
at Microsoft.Web.Services2.Configuration.WebServicesConfiguration.Initialize()
--- End of inner exception stack trace ---
at Microsoft.Web.Services2.Configuration.WebServicesConfiguration.Initialize()
at Microsoft.Web.Services2.WebServicesExtension.BeforeDeserializeServer(SoapServerMessage message)
--- End of inner exception stack trace ---

I had to spend some time fooling around the net to find the resolution. But I got it in the end.

The reason is that name of the dll that is output has changed in VS2005. Its usually called App_code. So kust make sure that your web.config file contains this dll name rather then the name
of the DLL based on the namespace that you are working on. The section is: securityTokenManager