Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF
Hi All,
I am a beginner in WCF, So please help me out. There is no IIS installed on my system.
So using Asp.net Web Development server.
 
This is my MathService.Svc file
<%@ ServiceHost Language="C#" Debug="true" Service="MathService" CodeBehind="~/App_Code/MathService.cs" %>
 
IMathService.cs  file which is the interface code
[ServiceContract]
public interface IMathService
{
    [OperationContract]
    int Add(int a, int b);
 
}
This is my MathService.cs code
public class Service : IMathService
{
 
    public int Add(int a, int b)
    {
        return a + b;
    }
}
When i try to add this service to a console application, i get the below error

The type 'MathService', provided as the Service attribute value in the ServiceHost directive 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 'MathService', provided as the Service attribute value in the ServiceHost directive could not be found.

 
In the Web.config file I have changed the config file as
<system.serviceModel>
        <services>
            <service name="MathService" behaviorConfiguration="ServiceBehavior">
                <!-- Service Endpoints -->
                <endpoint address="" binding="wsHttpBinding" contract="IMathService">
                    <!--
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          -->
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <!-- 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>
    </system.serviceModel>
Please let me know what is this error popping up.
I am using .Net framework 3.5 and VS 2010.
 
When i try to run the Default service i.e. Service.Svc it works fine.
Posted 23-Sep-12 5:25am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Check the namespaces for IService and Service.cs . Both should match
 
also in the contract value, add your namespace. servicecontract
 
like
   <endpoint address="" binding="wsHttpBinding" contract="namespace.IMathService"></endpoint>
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

yea Error is in client application server is absolutly correct check concumption again
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

have added the service reference to your console application?
you need to add it by selecting add reference option from solution explorer and u should import the reference to ur console application..
 
Let me knw if any confusions!!!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 165
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100