none
Metadata contains a reference that cannot be resolved, WCF - NEED URGENT HELP RRS feed

  • Question

  • have a WCF service issue. I made some changes to the service rename/added/removed services. Solution builds fine but when I reference this WCF service from a test solution...getting this error. It seems like there are some old references that haven't been removed. Looking for some feedback on how to resolve this. Thanks Jay

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Setting environment for using Microsoft Visual Studio 2010 x86 tools.

    c:\Program Files\Microsoft Visual Studio 10.0\VC>svcutil /t:metadata http://loca
    lhost:1141/Well/WellService.svc
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Attempting to download metadata from 'http://localhost:1141/Well/WellService.svc
    ' using WS-Metadata Exchange or DISCO.
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Error: Cannot obtain Metadata from http://localhost:1141/Well/WellService.svc

    If this is a Windows (R) Communication Foundation service to which you have acce
    ss, please check that you have enabled metadata publishing at the specified addr
    ess.  For help enabling metadata publishing, please refer to the MSDN documentat
    ion at http://go.microsoft.com/fwlink/?LinkId=65455.


    WS-Metadata Exchange Error
        URI: http://localhost:1141/Well/WellService.svc

        Metadata contains a reference that cannot be resolved: 'http://localhost:114
    1/Well/WellService.svc'.

        The server did not provide a meaningful reply; this might be caused by a con
    tract mismatch, a premature session shutdown or an internal server error.


    HTTP GET Error
        URI: http://localhost:1141/Well/WellService.svc

        There was an error downloading 'http://localhost:1141/Well/WellService.svc'.


        The request failed with the error message:
    --
    <html>
        <head>
            <title>The service cannot be activated because it does not support ASP.N
    ET compatibility. ASP.NET compatibility is enabled for this application. Turn of
    f ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityReq
    uirements attribute to the service type with RequirementsMode setting as 'Allowe
    d' or 'Required'.</title>
            <style>
             body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:bl
    ack;}
             p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5p
    x}
             b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

             H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red
    }
             H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maro
    on }
             pre {font-family:"Lucida Console";font-size: .9em}
             .marker {font-weight: bold; color: black;text-decoration: none;}
             .version {color: gray;}
             .error {margin-bottom: 10px;}
             .expandable { text-decoration:underline; font-weight:bold; color:navy;
    cursor:hand; }
            </style>
        </head>

        <body bgcolor="white">

                <span><H1>Server Error in '/' Application.<hr width=100% size=1 colo
    r=silver></H1>

                <h2> <i>The service cannot be activated because it does not support
    ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Tu
    rn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibili
    tyRequirements attribute to the service type with RequirementsMode setting as 'A
    llowed' or 'Required'.</i> </h2></span>

                <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">


                <b> Description: </b>An unhandled exception occurred during the exec
    ution of the current web request. Please review the stack trace for more informa
    tion about the error and where it originated in the code.

                <br><br>

                <b> Exception Details: </b>System.InvalidOperationException: The ser
    vice cannot be activated because it does not support ASP.NET compatibility. ASP.
    NET compatibility is enabled for this application. Turn off ASP.NET compatibilit
    y mode in the web.config or add the AspNetCompatibilityRequirements attribute to
    the service type with RequirementsMode setting as 'Allowed' or 'Required'.<br><
    br>

                <b>Source Error:</b> <br><br>

                <table width=100% bgcolor="#ffffcc">
                   <tr>
                      <td>
                          <code>

    An unhandled exception was generated during the execution of the current web req
    uest. Information regarding the origin and location of the exception can be iden
    tified using the exception stack trace below.</code>

                      </td>
                   </tr>
                </table>

                <br>

                <b>Stack Trace:</b> <br><br>

                <table width=100% bgcolor="#ffffcc">
                   <tr>
                      <td>
                          <code><pre>

    [InvalidOperationException: The service cannot be activated because it does not
    support ASP.NET compatibility. ASP.NET compatibility is enabled for this applica
    tion. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCom
    patibilityRequirements attribute to the service type with RequirementsMode setti
    ng as 'Allowed' or 'Required'.]
       System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityR
    equirements(AspNetCompatibilityRequirementsMode compatibilityMode) +160
       System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.Syste
    m.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription descript
    ion, ServiceHostBase serviceHostBase) +27
       System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(Service
    Description description, ServiceHostBase serviceHost) +196
       System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(Servi
    ceDescription description, ServiceHostBase serviceHost) +102
       System.ServiceModel.ServiceHostBase.InitializeRuntime() +62
       System.ServiceModel.ServiceHostBase.OnBeginOpen() +29
       System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +57
       System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +398
       System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPa
    th) +216
       System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVi
    rtualPath) +648

    [ServiceActivationException: The service '/Well/WellService.svc' cannot be activ
    ated due to an exception during compilation.  The exception message is: The serv
    ice cannot be activated because it does not support ASP.NET compatibility. ASP.N
    ET compatibility is enabled for this application. Turn off ASP.NET compatibility
    mode in the web.config or add the AspNetCompatibilityRequirements attribute to
    the service type with RequirementsMode setting as 'Allowed' or 'Required'..]
       System.Runtime.AsyncResult.End(IAsyncResult result) +439
       System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
    result) +188
       System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronou
    s(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext,
    Boolean ensureWFService) +230
       System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context
    ) +25
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep
    .Execute() +478
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& complete
    dSynchronously) +76
    </pre></code>

                      </td>
                   </tr>
                </table>

                <br>

                <hr width=100% size=1 color=silver>

                <b>Version Information:</b> Microsoft .NET Framework Version:4.0.303
    19; ASP.NET Version:4.0.30319.272

                </font>

        </body>
    </html>
    <!--
    [InvalidOperationException]: The service cannot be activated because it does not
    support ASP.NET compatibility. ASP.NET compatibility is enabled for this applic
    ation. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCo
    mpatibilityRequirements attribute to the service type with RequirementsMode sett
    ing as 'Allowed' or 'Required'.
       at System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibili
    tyRequirements(AspNetCompatibilityRequirementsMode compatibilityMode)
       at System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.Sy
    stem.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription descr
    iption, ServiceHostBase serviceHostBase)
       at System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(Serv
    iceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(Se
    rviceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.ServiceHostBase.InitializeRuntime()
       at System.ServiceModel.ServiceHostBase.OnBeginOpen()
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateServi
    ce(String normalizedVirtualPath)
       at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureService
    Available(String normalizedVirtualPath)
    [ServiceActivationException]: The service '/Well/WellService.svc' cannot be acti
    vated due to an exception during compilation.  The exception message is: The ser
    vice cannot be activated because it does not support ASP.NET compatibility. ASP.
    NET compatibility is enabled for this application. Turn off ASP.NET compatibilit
    y mode in the web.config or add the AspNetCompatibilityRequirements attribute to
    the service type with RequirementsMode setting as 'Allowed' or 'Required'..
       at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResu
    lt result)
       at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchro
    nous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContex
    t, Boolean ensureWFService)
       at System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext cont
    ext)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplica
    tion.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& compl
    etedSynchronously)
    -->
    --.

    If you would like more help, type "svcutil /?"

    c:\Program Files\Microsoft Visual Studio 10.0\VC>

    Friday, October 4, 2013 7:25 PM

Answers

  • Hi,

    >>Error: Cannot obtain Metadata from http://localhost:1141/Well/WellService.svc
    If this is a Windows (R) Communication Foundation service to which you have acce
    ss, please check that you have enabled metadata publishing at the specified addr
    ess.  For help enabling metadata publishing, please refer to the MSDN documentat
    ion at http://go.microsoft.com/fwlink/?LinkId=65455.

    When occur the above error, please make sure you have enabled the metadata as following:

    <services>  
    <service behaviorConfiguration="metadataBehavior" name="MyService">    
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />  
    </service>
    </services>
    <behaviors>  
    <serviceBehaviors>    
    <behavior name="metadataBehavior">      
    <serviceMetadata httpGetEnabled="true" />    
    </behavior>  
    </serviceBehaviors>
    </behaviors>

    In addition, please make sure your service references that behavior.

    <service name="MyService" behaviorConfiguration="metadataBehavior">

    >>The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

    When occur the above error, please mark your service as following:

    [AspNetCompatibilityRequirements(
            RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    Because when you set aspNetCompatibilityEnabled to true in your config file, you are stating that your services will participate in the ASP.NET pipeline; so items like ASP.NET session are available. You need to decorate your services appropriately if this is the case, since ASP.NET Compatibility Mode is set to false by default.
    So by decorating your service implementation with a RequirementsMode of Allowed, you're stating a happy middle ground that basically says your service doesn't care what the aspNetCompatibility mode is (true or false). If your RequirementsMode is Required, then you need to have the config aspNetCompatibilityEnabled set to true; the opposite is true if your RequirementsMode is set to NotAllowed.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, October 7, 2013 5:15 AM
    Moderator

All replies

  • Hi Jay,

      The error message "The ser
    vice cannot be activated because it does not support ASP.NET compatibility. ASP.
    NET compatibility is enabled for this application. Turn off ASP.NET compatibilit
    y mode in the web.config or add the AspNetCompatibilityRequirements attribute to
    the service type with RequirementsMode setting as 'Allowed' or 'Required' ", says that there is a Asp.NET compatibility issue in your WCF Service.

    Check out this reference: http://msdn.microsoft.com/en-us/library/ms752234.aspx . it may be helpfull.

    Regards

    Friday, October 4, 2013 7:52 PM
  • Hi,

    >>Error: Cannot obtain Metadata from http://localhost:1141/Well/WellService.svc
    If this is a Windows (R) Communication Foundation service to which you have acce
    ss, please check that you have enabled metadata publishing at the specified addr
    ess.  For help enabling metadata publishing, please refer to the MSDN documentat
    ion at http://go.microsoft.com/fwlink/?LinkId=65455.

    When occur the above error, please make sure you have enabled the metadata as following:

    <services>  
    <service behaviorConfiguration="metadataBehavior" name="MyService">    
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />  
    </service>
    </services>
    <behaviors>  
    <serviceBehaviors>    
    <behavior name="metadataBehavior">      
    <serviceMetadata httpGetEnabled="true" />    
    </behavior>  
    </serviceBehaviors>
    </behaviors>

    In addition, please make sure your service references that behavior.

    <service name="MyService" behaviorConfiguration="metadataBehavior">

    >>The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

    When occur the above error, please mark your service as following:

    [AspNetCompatibilityRequirements(
            RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    Because when you set aspNetCompatibilityEnabled to true in your config file, you are stating that your services will participate in the ASP.NET pipeline; so items like ASP.NET session are available. You need to decorate your services appropriately if this is the case, since ASP.NET Compatibility Mode is set to false by default.
    So by decorating your service implementation with a RequirementsMode of Allowed, you're stating a happy middle ground that basically says your service doesn't care what the aspNetCompatibility mode is (true or false). If your RequirementsMode is Required, then you need to have the config aspNetCompatibilityEnabled set to true; the opposite is true if your RequirementsMode is set to NotAllowed.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, October 7, 2013 5:15 AM
    Moderator