Since I'm contemplating to use WCF I thought it would be best to just follow a simple tutorial to get my feet wet.
3 hours later, I've only got one exception to show for. It won't go away.
I ruled out the app.config not being loaded. If I change: wsHttpBinding in the config to JHGHJGH it gives an error when running. However when I change the name of the contract interface, no errors are given (except the same one I'm facing for the last 3 hours)
Does anyone have an idea how to debug this? This kind of blackbox error stuff is very off-putting for me.
full exception:
Service 'WCFtest.TestService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element
(Don't you love these errors which indicate any of 16 possible things which might be wrong)
my program.cs
ServiceHost host;
Type serviceType = typeof(TestService);
host = new ServiceHost(serviceType);
host.Open(); //<---- exception is thrown here
Console.ReadLine();
my test 'wcf service'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace WCFtest
{
[ServiceContract]
public interface ITest
{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
}
public class TestService : ITest
{
public double Add(double n1, double n2)
{
double result = n1 + n2;
return result;
}
etc... some methods are removed for brevity
}
}
my app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFtest.testservice"
behaviorConfiguration="testservicebehaviour">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/test"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
contract="WCFtest.ITest" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="testservicebehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>