I am not using "using" statement, the code looks like this:
partial class HeimdallClientService : ServiceBase
{
ServiceHost m_HmdlService;
public HeimdallClientService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
StartService();
}
protected override void OnStop()
{
StopService();
}
protected override void OnPause()
{
StopService();
}
protected override void OnContinue()
{
StartService();
}
public static void Main()
{
ServiceBase.Run(new HeimdallClientService());
}
void StartService()
{
if (m_HmdlService != null)
m_HmdlService.Close();
m_HmdlService = new ServiceHost(typeof(HeimdallService));
m_HmdlService.Open();
}
void StopService()
{
if (m_HmdlService != null)
{
m_HmdlService.Close();
m_HmdlService = null;
}
}
}
Thanks.
From the exception you've shown, I suspect you are coding with "using"
when accessing the WCF generated proxy, right?
[CommunicationObjectFaultedException: The communication object,
System.ServiceModel.Channels.ServiceChannel, cannot be used for
communication because it is in the Faulted state.]
If so, then change the code to look like this:
Proxy c = new Proxy()
try
{
c.CallMethod();
}
finally
{
try { c.Close(); }
catch(Exception) { c.Abort(); }
}
The original exception will bubble up and will tell you what caused
the error.
Tiago Halm
Hi Tiago,
here are some more details:
Stack trace:
[CommunicationObjectFaultedException: The communication object,
System.ServiceModel.Channels.ServiceChannel, cannot be used for
communication because it is in the Faulted state.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) +2668969
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) +717
System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) +0
System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan
timeout) +177
System.ServiceModel.ClientBase`1.Close() +38
System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() +4
System.Web.UI.WebControls.ObjectDataSourceView.ReleaseInstance(Object
instance) +75
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments) +2176
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +92
System.Web.UI.WebControls.ListControl.PerformSelect() +31
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+2041
Here is service configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior
name="Com.Fbfs.Eworld.Heimdall.ClientService.HeimdallServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service
behaviorConfiguration="Com.Fbfs.Eworld.Heimdall.ClientService.HeimdallServiceBehavior"
name="Com.Fbfs.Eworld.Heimdall.ClientService.HeimdallService">
<endpoint address="" binding="wsHttpBinding"
contract="Com.Fbfs.Eworld.Heimdall.ClientService.IHeimdallService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add
baseAddress="
http://localhost:8731/Design_Time_Addresses/Com.Fbfs.Eworld.Heimdall...."/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
And web client configuration:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHeimdallService"
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="2147483647"
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" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint
address="
http://localhost:8731/Design_Time_Addresses/Com.Fbfs.Eworld.Heimdall...."
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IHeimdallService"
contract="Com.Fbfs.Eworld.HeimdallClientService.IHeimdallService"
name="WSHttpBinding_IHeimdallService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Console client (which doesn't throw exception) does have identical
configuration.
Thanks.
Details on the exception would be useful, like stack trace, message
and
any inner exception involved.
Tiago Halm
Hi
I changed from XP to Vista and now when my web client call service
(WCF)
hosted by windows service I get CommunicationObjectFaultedException
(it
did work fine under the XP). Service is using wsHttpBinding. I
created
a
console client to call same service and that works without any
problems.
Anyone with same/similar problem?
Thanks.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -