AMH
AMH

Reputation: 6451

What's wrong with this WCF

I created web service library like in this link http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec

To publish it I followed the link http://naztek.wordpress.com/2009/08/27/host-a-wcf-library-in-iis/

but I got this error at run time

Server Error in '/WCFService1' Application.

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

My web.config is :

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="test1.Try">
        <endpoint address="http://localhost:8732/Try" binding="webHttpBinding" contract="test1.Try"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

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.

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

Upvotes: 2

Views: 3449

Answers (1)

Grzegorz W
Grzegorz W

Reputation: 3517

It looks to me like You missed Step 3 from the second link (about publishing). Especially this part:

Change the Service attribute value from Service to the fully qualified name of the concrete class in our WCF library, e.g., RegistrationServiceLib.RegistrationService

To open svc file use right click -> open with -> XML (text) editor

You should see something like this:

<%@ ServiceHost Language="C#" Debug="true" Service="YourNamespace.Service" CodeBehind="Service.svc.cs" %>

Change this to match your service (just like your tutorial stated).

Upvotes: 1

Related Questions