Reputation: 1284
I am currently learning WCF and I have a very weird problem.
I have created a WCF service and hosted in a console application. I created a client and when I start debugging the client everything works as expected. The browser hits the address specified in the service. But, when I just run the client without debugging I get an exception. The entire time I have not touched the service. Only the client. The service is hosted in a console application.
I also noticed something very weird. I put a console.readline() in client. Now while debugging client, when I attach the debugger, I see a WCF service desktop notification that tells me service is hosted and I am able to use the service and it works. I can also access the address via browser. If i detach the debugger, address does not work in browser. If I re- attach then it works again, another desktp notification appears. This tells me my Service is up and running when I debug only. When I exit the debugger, the service exits. But I am not touching the service, the entire time just the client.
Pleaseeee tell me I am not crazy :(
MyAddress:
http://localhost:8732/Design_Time_Addresses/MASService/Service1/
Exception: There was no endpoint listening at [MyAddress] that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
This is my service configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="MASService.MasOperationsService" behaviorConfiguration="SimpleServiceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="MASService.IMasOperations">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MASService/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<!-- 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>
</configuration>
This is my service host configuration (console app):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="MASService.MasOperationsService">
<endpoint address="http://localhost:8733/Design_Time_Addresses/MASService/Service1"
binding="basicHttpBinding" bindingConfiguration="" contract="MASService.IMasOperations" />
</service>
</services>
</system.serviceModel>
</configuration>
This is my client configuration (console app):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMasOperations" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/MASService/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMasOperations"
contract="ServiceReference1.IMasOperations" name="WSHttpBinding_IMasOperations">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Upvotes: 0
Views: 1266
Reputation: 65
You need to mark the file that ends in SVC as the start page of your project in Visual Studio by right clicking it in the solution explorer. Then the client will start automatically.
Upvotes: 2
Reputation: 862
The client will need the port to which the console app is exposing the service. I imagine when running the debugger vs is hosting on the port your client is successfully connecting to. (Would have added this as a comment, but my nexus client does not appear to support comments) try 8733 and the bindings should match.
Upvotes: 1