zoukankan      html  css  js  c++  java
  • (WCF) WCF and Service Debug

    需要做一个多程序间的通讯,采用WCF和WCF Service是目前的选择。

    需求:和产品进行通讯,和用户有交互操作,并将最后结果传送个DB

    基本思路:

    1. 用WPF客户端程序和产品进行通讯,获取必要的结果。

    2. WPF客户端程序里调用WCF 的Proxy, 将结果传送个WCF Service。

    3. 另外一个程序通过另一个WCF Proxy获取结果,并传送到DB

    Control System(Service)             <-------------------->   WCF Service (Host in Windows Service) <----------------------->   UI Application

              |                                                                                                                                                                          | (Comunication)

           WCF Client(Proxy, GetResult) Device.

              |

           Upload to DB

    基本实现:

    1.  创建WCF Service Library, 实现 WCF Service 的接口。

    2.  创建Windows Service, 并将WCF Service Host 到 Windows Service.

    3.  创建WPF UI 程序,实现和Device的通讯。

    问题和Debug:

    1. Service出现问题的时候,可以用EventViewer来协助Debug。

    参考:

    1. http://blog.csdn.net/hebeijg/article/details/6161228

    2. http://www.codeproject.com/Articles/38160/WCF-Service-Library-with-Windows-Service-Hosting

    --------------------

    Debug WCF 通讯的时候,应该采用 SvcTraceViewer.exe 工具

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/service-trace-viewer-tool-svctraceviewer-exe

    三步:
    1. 在 Host 端的Config文件里面添加 <system.diagnostics> node内容。具体参考上面连接。注意指定 svclog 文件的路径。
    2. 运行WCF 程序 (Host, Client)进行通讯。
    3. 用SvcTraceViewer工具打开生成的svclog文件。就可以定位到错误发生行。

    --------------

    另外还可以通过在ServiceHost端增加internalerror 来得到准确的错误。

                       // Enable "IncludeExceptionDetailInFaults".
                        ServiceDebugBehavior debug = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
    
                        // if not found - add behavior with setting turned on 
                        if (debug == null)
                        {
                            serviceHost.Description.Behaviors.Add(
                                 new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
                        }
                        else
                        {
                            // make sure setting is turned ON
                            if (!debug.IncludeExceptionDetailInFaults)
                            {
                                debug.IncludeExceptionDetailInFaults = true;
                            }
                        }
  • 相关阅读:
    ATM项目分析
    Python常用模块大全
    一文了解@Conditional注解说明和使用
    Spring IOC源码分析之-刷新前的准备工作
    Spring Cloud Zuul API服务网关之请求路由
    ArrayList相关方法介绍及源码分析
    记一次序列化的JSON解析问题
    大型网站架构演化发展历程
    Spring Cloud Ribbon负载均衡
    Spring Cloud Hystrix 服务容错保护
  • 原文地址:https://www.cnblogs.com/fdyang/p/4246089.html
Copyright © 2011-2022 走看看