WCF requires precompiled ASP.Net sites to be updatable

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.

 

Published 30 January 2008 12:01 by Damien McGivern
Filed under: , , ,

Comments

# re: WCF requires precompiled ASP.Net sites to be updatable

06 May 2008 01:45 by David

Thanks for this Damien. Very helpful.

Regards,

David

# re: WCF requires precompiled ASP.Net sites to be updatable

04 June 2008 16:56 by Tom Fuller - MSFT

Damien,

My name is Tom Fuller and I work for Microsoft on the WCF support team.  I just worked through this issue with another customer and we found that you do *not* need to make the web application project as updateable to get WCF services to work.  The only tricky part is keeping the application project name and virtual directory name in sync.  If you don't you'll need to fix the customString node in the .compile file.  I have written up some instructions at forums.microsoft.com/.../ShowPost.aspx

# re: WCF requires precompiled ASP.Net sites to be updatable

13 June 2008 11:46 by Paras

Thanks, this was really helpful.

~Paras

# re: WCF requires precompiled ASP.Net sites to be updatable

16 June 2008 16:05 by Adam Kahtava

Thanks you just saved me a lot of time!

# re: WCF requires precompiled ASP.Net sites to be updatable

20 November 2008 11:03 by Harshil Patel

Thanks Tom Fuller,

You saved a lot of time for me too.

I have solved the problem by doing as you suggested on local IIS.

Now i am facing a problem while hosting it on Godady . I get an xml error saying :

-----

XML Parsing Error: no element found

Location: mydomain.com/myWCFService.svc

Line Number 1, Column 1:

-----

any idea what could be wrong sir ?

# re: WCF requires precompiled ASP.Net sites to be updatable

18 March 2009 18:07 by Bruno Kenj

Thanks for the time....

Leave a Comment

(required) 
(required) 
(optional)
(required)