none
Converted to VS2010, now service reference won't update.

    Question

  • I converted my project from VS2008 to VS2010 and left it referencing .NET 3.5.   Everything works fine except for the service reference.  It won't generate the files because it is having issues parsing the app.config.  The error it gives is:

    The configuration for the service reference could not be updated due to the following issue: An error occurred creating the 
    configuration section handler for system.serviceModel/behaviors: Extension element 'webHttp' cannot be added to this element.
    Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.

    When I manually define webHttp in the app.config like so:

     

      <extensions>
       <behaviorExtensions>
        <add name="webHttp" type="System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       </behaviorExtensions>
       <bindingElementExtensions>
        <add name="webMessageEncoding" type="System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       </bindingElementExtensions>
      </extensions>		
    
    it tells me 'webHttp is already defined and keys need to be unique.

    I've found one other issue like this on stackoverflow but no one replied.   http://stackoverflow.com/questions/1867489/vs-2010-beta-2-unable-to-update-service-reference

    Does anyone have any ideas on how to fix this?

    Tuesday, May 04, 2010 7:21 PM

All replies

  • Hi Modian,

    Regarding on the error you received, it indicates that there is something wrong with the webhttp behavior extensions. This behavior does be added in .NET 3.5(WCF 3.5), however, the behavior extension should be added in the machine.config file under your .NET framework 2.0 location(.NET 3.5 and 3.0 just derived from .NET 2.0). e.g.:

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

    Therefore, you should not have this behavior extension defined in your own project's app.config file(it should already defined in machine.config). You can verify this in the .net framework 2.0 machine.config file.

    Also, as you said that you've upgrated the project to vs 2010, then is it a web project hosting in IIS?  If so, you need to verify whether the IIS virtual directory has been changed to use a .NET 4.0 application pool. To continue use .NET 3.5, you need to switch the IIS virtual directory use .NET 2.0 application pool.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mog Liang Tuesday, May 11, 2010 5:51 AM
    • Unmarked as answer by Modian Tuesday, May 11, 2010 5:39 PM
    Thursday, May 06, 2010 5:44 AM
  • Hi Steven,

    Verifying the extension was in the machine.config was one of the first things I did, based on earlier threads that were somewhat related.  The definition exists in both the 2.0 config and the 4.0 config.   One of the answers on this forum mentioned defining those extensions in the app.config to fix an issue, which is why I tried that.

    Also, this isn't a web application - it's a WPF application.

    I forgot to include my code from the app.config in my original post, so here it is (slightly cleansed.)

     

     <system.serviceModel>
      <bindings>
       <basicHttpBinding>
         <binding name="ErrorReportingServiceSoap" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
        </binding>
       </basicHttpBinding>
       </bindings>
      <behaviors>
       <endpointBehaviors>
        <behavior name="restBehavior">
         <webHttp/>
        </behavior>
       </endpointBehaviors>
      </behaviors>
      <client>
       <endpoint address="http://someserver/ErrorReporting/ErrorReportingService.asmx"
        binding="basicHttpBinding" bindingConfiguration="ErrorReportingServiceSoap"
        contract="ErrorReportingService.ErrorReportingServiceSoap" name="ErrorReportingServiceSoap" />
       <endpoint address="http://someserver/rest.svc"
            binding="webHttpBinding"
            behaviorConfiguration="restBehavior"
            contract="OurApp.Modules.Import.Services.IModuleApi"
            name="SBT_REST" />
      </client>
     </system.serviceModel>
    

     

    So when I try to regenerate the ErrorReportingService, it bombs out due to an error parsing the configuration:

    "The configuration for the service reference could not be updated due to the following issue: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'webHttp' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions."

    If I remove that behavior and the endpoint that uses it, the service generates fine. If I run the application with those defined, everything works fine.  So, at the moment, I need to remove those definitions whenever I want to re-generate the service reference code, and then add them back in afterward

    Tuesday, May 11, 2010 6:12 PM
  • Hi Modian,

    As for the web application or not, I mean the WCF service , not the client caller application(which generate WCF service reference against the service).

    So the current problem behavior has been isolated to the webhttp behavior element, when adding it in your service or client proxy's behavior, it will raise error, correct?  Have you tried creating a new WCF service (use REST and webHttpbinding) in VS 2010 and consume it through ServiceReference in a client project to see whether it works?  if so, you can try comparing the two project(include app.config and project settings) for any difference. Or you can even try moving the files and components from the old(converted) project to the new created one in case the original project/solution has something incorrect.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, May 12, 2010 3:26 AM
  • Has this been solved? Even I had an identical issue ....I had a VS 2008 solution with a WCF service reference and then we converted it to VS 2010 and now when I update the Reference I get the same error...

     

    Extension element 'webHttp' cannot be added in this element. Verify that the extension is registered in the...etc.

    And if you remove the webHTTP it does go ahead but then I get an error in Reference.SvcMap and it does not compile.

    I have attached the code snippet of the web.config

    <system.serviceModel>
    		<behaviors>
    			<serviceBehaviors>
    				<behavior name="xxxxxxx.Services.AutoComplete.MasterServiceBehavior">
    					<serviceMetadata httpGetEnabled="true"/>
    					<serviceDebug includeExceptionDetailInFaults="false"/>
    				</behavior>
    			</serviceBehaviors>
     
     <endpointBehaviors>
     <behavior name="JsonServiceEndpointBehavior">
     <webHttp/> </behavior>
     </endpointBehaviors>
     </behaviors>
     
    
     <services>
    			<service behaviorConfiguration="xxxxxx.Services.AutoComplete.MasterServiceBehavior" name="Kale.Logistics.UPLIFT.UI.Services.AutoComplete.MasterService">
    				<endpoint address="" binding="webHttpBinding" contract="xxxxxxx.AutoComplete.IMasterService" behaviorConfiguration="JsonServiceEndpointBehavior">
    					<identity>
    						<dns value="localhost"/>
    					</identity>
    				</endpoint>
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    			</service>
    Tuesday, January 11, 2011 12:07 PM
  • The thread originator never responded, so we don't know what happened with the problem. I will reiterate what Steven suggested to him:

    Try creating a new WCF service (use REST and webHttpbinding) in VS 2010 and consume it through ServiceReference in a client project to see whether it works.  if so, you can try comparing the two projects (include app.config and project settings) for any differences. Or you can even try moving the files and components from the old (converted) project to the new created one in case the original project/solution has something incorrect.

    Please let us know how it goes for you,

    Michael Green
    WCF Documentation Team

    Wednesday, January 12, 2011 2:13 AM
  • Actually the WCF reference is still in VS 2008...only the invoking Web Application has been bumped up to VS 2010  and this project has a Service Reference that has been giving issue. And this issue only cropped up after I went to Update Service Reference. Before that the solution was working smoothly.

     

    AC

    Wednesday, January 12, 2011 5:39 AM
  • Well the actual WCF project is still in 2008. The invoking Web Project has been bumped upto VS 2010. And even after the web project was upgraded it was working fine...but after making a few changes to the WCF project...when I went to do a Update Service reference in the web project I have been getting that error which is now refusing to go...

    The only way I can take this forward is to remove the webHTTP from the web.config but then the issue crops up and the Reference.svcmap is malformed.

     

     

    Wednesday, January 12, 2011 6:06 AM
  • Ok when I upgraded the calling web application project  from .net 3.5 to 4.0 ....it started to work....and when I go back to 3.5...it again fails ...It looks like if the existing VS 2008 application is migrated to VS 2010 but still retains the 3.5 framework the Update Service Reference will fail even though the WCF Project still targets VS 2008 and .net 3.5.

    But i dont know how to now resolve the issue if I want to retain the 3.5 framework in the calling application.

     

    Thursday, January 13, 2011 5:37 AM
  • Hmmm, interesting.  What happens if you delete the existing reference and then re-add it instead of updating it? Do you see the same behavior?

    Thanks,

    Michael Green
    WCF Documentation Team

    Thursday, January 13, 2011 6:00 PM
  • I delete the existing reference, then re-add and that fixes my problem. 
    Wednesday, May 18, 2011 8:51 PM