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
<br />
The type 'MathService', provided as the Service attribute value in the ServiceHost directive could not be found.<br />
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.<br />
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">
<endpoint address="" binding="wsHttpBinding" contract="IMathService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<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.