Today I was testing a deployment ASP.Net site build that I added some WCF services to. All other non deployment builds passed all testing so I was stumped when testing one of the services I got the following error.
Value cannot be null.
Parameter name: key
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details:
System.ArgumentNullException: Value cannot be null.
Parameter name:
key
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
Stack Trace:
[ArgumentNullException: Value cannot be null. Parameter name: key] System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) +51 System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +5295964 System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +20 System.ServiceModel.Activation.MetabaseSettingsIis.GetTransportSettings(String virtualPath) +154 System.ServiceModel.Activation.MetabaseSettingsIis.GetAccessSslFlags(String virtualPath) +9 System.ServiceModel.Activation.HttpHostedTransportConfiguration.GetBaseAddresses(String virtualPath) +113 System.ServiceModel.Activation.HostedTransportConfigurationManager.InternalGetBaseAddresses(String virtualPath) +146 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +162 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +46 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +738
[ServiceActivationException: The service '/demo2/services/memberservice.svc' cannot be activated due to an exception during compilation. The exception message is: Value cannot be null. Parameter name: key.] System.ServiceModel.AsyncResult.End(IAsyncResult result) +7571873 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +4504815 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +288 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +273 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +177
|
Version Information: Microsoft .NET Framework Version:2.0.50727.1433;
ASP.NET Version:2.0.50727.1433
The only difference with the deployment build is that the website is precompiled and the assemblies merged. Then I checked the even log and noticed that for every request of memberservice.svc the following two errors occurred.
Event Type: Error
Event Source: System.ServiceModel 3.0.0.0
Event Category: WebHost
Event ID: 3
Date: 30/01/2008
Time: 11:30:35
User: NT AUTHORITY\NETWORK SERVICE
Computer: ELGRECO
Description:
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/30607723
Exception: System.ServiceModel.ServiceActivationException: The service '/demo2/services/memberservice.svc' cannot be activated due to an exception during compilation. The exception message is: Value cannot be null.
Parameter name: key. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.ServiceModel.Activation.MetabaseSettingsIis.GetTransportSettings(String virtualPath)
at System.ServiceModel.Activation.MetabaseSettingsIis.GetAccessSslFlags(String virtualPath)
at System.ServiceModel.Activation.HttpHostedTransportConfiguration.GetBaseAddresses(String virtualPath)
at System.ServiceModel.Activation.HostedTransportConfigurationManager.InternalGetBaseAddresses(String virtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
--- End of inner exception stack trace ---
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
Process Name: w3wp
Process ID: 708
Followed by:
Event Type: Error
Event Source: System.ServiceModel 3.0.0.0
Event Category: WebHost
Event ID: 3
Date: 30/01/2008
Time: 11:30:35
User: NT AUTHORITY\NETWORK SERVICE
Computer: ELGRECO
Description:
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/49972132
Exception: System.ServiceModel.ServiceActivationException: The service '/demo2/services/memberservice.svc' cannot be activated due to an exception during compilation. The exception message is: Value cannot be null.
Parameter name: key. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.ServiceModel.Activation.MetabaseSettingsIis.GetTransportSettings(String virtualPath)
at System.ServiceModel.Activation.MetabaseSettingsIis.GetAccessSslFlags(String virtualPath)
at System.ServiceModel.Activation.HttpHostedTransportConfiguration.GetBaseAddresses(String virtualPath)
at System.ServiceModel.Activation.HostedTransportConfigurationManager.InternalGetBaseAddresses(String virtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
Process Name: w3wp
Process ID: 708
After a bit of searching I found the following post http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1150859&SiteID=1 which states that WCF hosted in a precompiled ASP.Net site requires the site to be updatable. So adding the -u switch to our build scrip which calls aspnet_compiler solved the problem.