0
votes

I'm using wcf library in windows service my wcf libray contain one project dll which contains data access layer. When I try to start my windows service then my windows service is unable to start

Exception :

Service cannot be started. System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(...

For this we use in App Config

My service call is

using (ServiceReference1.Service1Client c = new ServiceReference1.Service1Client())
            {
                c.GetZvol();
                c.ChannelFactory.Close();
                c.Close();
            }

But after adding this it givs another Exception while starting windows service

Exception :

Service cannot be started. System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace: at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) at System.ServiceModel.ClientBase1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) at System.ServiceModel.ClientBase1.Close() at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() at ClassDemo.Class1.CreateFile() in C:\Users\vikram\Documents\visual studio 2010\Projects\mcWindowsService\ClassDemo\Class1.cs:line 21 at mcWindowsService.Service1.OnStart(String[] args) ...

Please anyone tell me the solution

1

1 Answers

1
votes

You cant host and call a wcf service from the same process. Your windows service should only host the wcf dll and you can make calls to it from another process like a winforms app or web app.