Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows服务中的Wcf库_C#_Wcf - Fatal编程技术网

C# Windows服务中的Wcf库

C# Windows服务中的Wcf库,c#,wcf,C#,Wcf,我正在windows服务中使用wcf库我的wcf库包含一个包含数据访问层的项目dll。当我尝试启动windows服务时,我的windows服务无法启动 例外情况: 服务无法启动。 System.ServiceModel.FaultException: 服务器无法处理该请求 由于内部错误导致的请求。对于 有关错误的更多信息, 要么打开 IncludeExceptionDetailInFaults(或 来自ServiceBehaviorAttribute或来自 配置 行为),以便 将异常信息发送回

我正在windows服务中使用wcf库我的wcf库包含一个包含数据访问层的项目dll。当我尝试启动windows服务时,我的windows服务无法启动

例外情况:

服务无法启动。 System.ServiceModel.FaultException: 服务器无法处理该请求 由于内部错误导致的请求。对于 有关错误的更多信息, 要么打开 IncludeExceptionDetailInFaults(或 来自ServiceBehaviorAttribute或来自 配置 行为),以便 将异常信息发送回 客户端,或根据打开跟踪 Microsoft.NET Framework 3.0 SDK 记录并检查服务器 跟踪日志

服务器堆栈跟踪:在 System.ServiceModel.Channels.ServiceChannel.ThrowiffaultUnderstanding(消息 回复,MessageFault,字符串 操作,消息版本, 故障转换器(故障转换器)位于 System.ServiceModel.Channel.ServiceChannel.HandlerReply(ProxyOperationRuntime 操作,ProxyRpc&rpc)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,布尔单向, ProxyOperationRuntime操作, 对象[]输入,对象[]输出,时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(

为此,我们在应用程序配置中使用

我的服务电话是

using (ServiceReference1.Service1Client c = new ServiceReference1.Service1Client())
            {
                c.GetZvol();
                c.ChannelFactory.Close();
                c.Close();
            }
但在添加此项后,在启动windows服务时会出现另一个异常

例外情况:

服务无法启动。 System.ServiceModel.CommunicationObjectFaultedException: 通信对象, System.ServiceModel.Channel.ServiceChannel, 不能用于通信 因为它处于故障状态

服务器堆栈跟踪:在 System.ServiceModel.Channel.CommunicationObject.Close(时间跨度 超时)

在[0]处重试异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32类型)at System.ServiceModel.ICommunicationObject.Close(TimeSpan 超时)在 System.ServiceModel.ClientBase
1.System.ServiceModel.ICommunicationObject.Close(TimeSpan
超时)在
System.ServiceModel.ClientBase
1.Close() 在 System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() 在中的ClassDemo.Class1.CreateFile()处 C:\Users\vikram\Documents\visual 演播室 2010\Projects\mcWindowsService\ClassDemo\Class1.cs:line 21时 mcWindowsService.Service1.OnStart(字符串[]) args)


请告诉我解决方案

你不能从同一进程托管和调用wcf服务。你的windows服务应该只托管wcf dll,你可以从另一个进程(如winforms应用程序或web应用程序)调用它。

我正在使用云计算备份实用程序,因为我使用的是windows服务,该服务在数据库和包含在wcf服务中的数据库监控业务逻辑这就是为什么我需要从windows服务托管和调用该服务是他们的另一个解决方案看看这个线程如何从其主机窗口服务本身与wcf服务通信:这里我在windows服务的onstart事件上托管我的服务,在这个wi中ndows服务我在该项目中使用另一个项目dll我们添加了该服务引用,该服务引用托管在onstart事件中,该wcf包含另一个项目dll该dll包含DataAccess层代码。如果您无法理解,如果您没有提及,请将您的邮件id发送给我我已将我的应用程序发送给您谢谢我无法从windows服务连接到SQL server