I have read numerous different things about WCF in C#, but still haven't found a satisfactory answer to my noopy problem, yet. (I'm new to C# and .NET)
When i run my selfhosted WCF Service inside VS everything works fine. It also works fine when I run the generated exe-file (clientdir\bin\debug\consoleApp.exe) of my client application while VS is running. However, when I run the generated exe-file(s) (clientdir\bin\debug\consoleApp.exe and hostdir\bin\debug\consoleApp.exe) while VS is not running, I get an EndpointNotFoundException.
Here's the App.config of my client application:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ImyService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1592/myService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ImyService"
contract="refmy.ImyService" name="BasicHttpBinding_ImyService" />
</client>
</system.serviceModel>
</configuration>
And here's the App.config of my host application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDiscovery />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetadataBehavior" name="my.myService">
<endpoint binding="basicHttpBinding" bindingConfiguration="" name="httpEndpoint" contract="my.ImyService" />
<endpoint binding="netTcpBinding" bindingConfiguration="" name="netTcpEndpoint" contract="my.ImyService" />
<endpoint address="MEX" binding="mexTcpBinding" bindingConfiguration="" name="mexEndpoint" contract="IMetadataExchange" />
<endpoint name="udpDiscovery" kind="udpDiscoveryEndpoint" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:9400/myService" />
<add baseAddress="net.tcp://localhost:9500/myService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
This is the C# code of my host application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using my;
namespace myHost
{
class Program
{
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(myService));
host.Open();
Console.ReadLine();
}
}
}