locked
WCF hosting error: service not found; Need help! RRS feed

  • Question

  • I have a service library which works fine when tested in Visual Studio.  I added an IIS hosting project.  When I try to "view in browser" the IIS host service, I get an error - unhandled exception - and a message that the service cannot be found.

    All settings appear correct.  In fact I have a second sample project which is very similar but for another service library, and it has no problem.  

    Complete error message is:

    Server Error in '/flelisGenericService' Application.

    The type 'flelisGenericWebServiceLibrary.flelisService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

    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.InvalidOperationException: The type 'flelisGenericWebServiceLibrary.flelisService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

    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:

    [InvalidOperationException: The type 'flelisGenericWebServiceLibrary.flelisService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.]
      System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +52042
      System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
      System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
      System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615
    
    [ServiceActivationException: The service '/flelisGenericService/flelisGeneric.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'flelisGenericWebServiceLibrary.flelisService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
      System.Runtime.AsyncResult.End(IAsyncResult result) +687598
      System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
      System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
      System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355
      System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
      System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225 

    Tuesday, July 26, 2011 6:32 AM

Answers

  • use the serviceCredentials in the serviceBehavior section to set the service's credentials

    http://msdn.microsoft.com/en-us/library/ms731899.aspx


    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    • Proposed as answer by Ido Flatow. _ Tuesday, July 26, 2011 7:30 AM
    • Marked as answer by Yi-Lun Luo Wednesday, July 27, 2011 1:51 AM
    Tuesday, July 26, 2011 7:05 AM

All replies

  • Can you please show us the configuration file (web.config)?

    And also the content of the .svc file (unless you use the serviceActivation configuration in web.config)

     


    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    • Proposed as answer by Ido Flatow. _ Tuesday, July 26, 2011 7:30 AM
    • Unproposed as answer by Ido Flatow. _ Tuesday, July 26, 2011 7:30 AM
    Tuesday, July 26, 2011 6:38 AM
  • Sure.  I can send complete code if you give me an upload or email address.  The example is very small.

    -------------

    <%@ ServiceHost Language="C#" Debug="true" Service="flelisGenericWebServiceLibrary.flelisService" %>

    -------------

    <?xml version="1.0"?>

    <configuration>

     

      <system.web>

        <compilation debug="false" targetFramework="4.0" />

      </system.web>

      <system.serviceModel>

        <services>

          <service name="flelisGenericServiceLibrary.flelisService">

            <clear />

            <endpoint binding="ws2007HttpBinding" bindingConfiguration="" contract="flelisGenericServiceLibrary.IflelisService"

              listenUriMode="Explicit">

              <identity>

                <certificateReference storeName="My" storeLocation="LocalMachine"

                  x509FindType="FindBySubjectDistinguishedName" />

              </identity>

            </endpoint>

            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""

              contract="IMetadataExchange" />

            <host>

              <baseAddresses>

                <add baseAddress="http://localhost:8085/flelisGenericService" />

              </baseAddresses>

            </host>

          </service>

        </services>

        <behaviors>

          <serviceBehaviors>

            <behavior>

              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->

              <serviceMetadata httpGetEnabled="true"/>

              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->

              <serviceDebug includeExceptionDetailInFaults="false"/>

            </behavior>

          </serviceBehaviors>

        </behaviors>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

      </system.serviceModel>

      <system.webServer>

        <modules runAllManagedModulesForAllRequests="true"/>

      </system.webServer>

     

    </configuration>

    Tuesday, July 26, 2011 6:45 AM
  • Check the namespace in the .svc file and in the web.config - it is different.
    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    • Proposed as answer by Ido Flatow. _ Tuesday, July 26, 2011 7:30 AM
    Tuesday, July 26, 2011 6:48 AM
  • interesting.   So I fiddled with the namespace and now I'm getting an X509 certificate error
    akg
    Tuesday, July 26, 2011 6:58 AM
  • I seem to recall I need to add a "host" entry to my webconfig to get around this.  but don't recall what entry
    akg
    Tuesday, July 26, 2011 7:00 AM
  • use the serviceCredentials in the serviceBehavior section to set the service's credentials

    http://msdn.microsoft.com/en-us/library/ms731899.aspx


    Please mark posts as answers/helpful if it answers your question. Senior Consultant on WCF, ASP.NET, Siverlight, and Entity Framework. Author of Microsoft's Official WCF 4 Course. Co-author of the Microsoft HPC/Azure burst whitepaper. Visit my blog: http://blogs.microsoft.co.il/blogs/idof
    • Proposed as answer by Ido Flatow. _ Tuesday, July 26, 2011 7:30 AM
    • Marked as answer by Yi-Lun Luo Wednesday, July 27, 2011 1:51 AM
    Tuesday, July 26, 2011 7:05 AM
  • Thanks.  I reset the identity components all to localhost, and now it appears to work.  But I will read the link above.
    akg
    Tuesday, July 26, 2011 7:17 AM
  • Thanks.  I reset the identity components all to localhost, and now it appears to work.  But I will read the link above.
    akg
    Tuesday, July 26, 2011 7:17 AM