Since I plan on using WCF, I thought it was best to just follow a simple tutorial to keep my feet wet.
After 3 hours, I have only one exception. It will not disappear.
I ruled out that app.config is not loading. If I change: wsHttpBinding in config to JHGHJGH, it gives an error on startup. However, when I change the name of the contract interface, no errors are generated (except for the one I have encountered in the last 3 hours)
Does anyone have an idea how to debug this? This kind of black box error is very unsuitable for me.
full exception:
The WCFtest.TestService service has a null application (not infrastructure) endpoints. This may be because no configuration file was found for your application, or because there is no service element matching the name of the service can be found in the configuration file, or because no endpoints were defined in the service element
(You don't like these errors, pointing to any of the 16 possible things that may 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 is '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>
source
share