在Visual Studio中调试WCF服务时出现异常 [英] Exception While Debugging WCF service in Visual Studio

查看:93
本文介绍了在Visual Studio中调试WCF服务时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我使用Visual Studio 2013创建了一个简单的WCF服务..代码为:



Hello ,

I have created a simple WCF service using Visual Studio 2013.. The code for which is :

[ServiceContract]
    public interface IService2
    {
        [OperationContract]
        Int32 ADD(Int32 num1 , Int32 num2);

        [OperationContract]
        Int32 MULTIPLY(Int32 num1, Int32 num2);

        [OperationContract]
        Int32 SUBTRACT(Int32 num1, Int32 num2);

        [OperationContract]
        Int32 DIVISION(Int32 num1, Int32 num2);











and

public Int32 ADD(Int32 num1, Int32 num2)
       {
           return num1 + num2;
       }

       public Int32 MULTIPLY(Int32 num1, Int32 num2)
       {
           return num1 - num2;
       }


       public Int32 SUBTRACT(Int32 num1, Int32 num2)
       {
           return num1 * num2;
       }

       public Int32 DIVISION(Int32 num1, Int32 num2)
       {
           if (num2.Equals(0))
           {
               return num1;
           }
           else
           {
               return num1 / num2;
           }
       }





但是当我开始调试时它给出了以下异常,除了
mscorlib.dll中发生了一个未处理的System.Reflection.TargetInvocationException类型异常......任何人都可以在这方面帮助我吗?谢谢



but when i start debugging it gives following exception exceptio
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll ... can anyone assist me in this regard ? thanks

推荐答案

根据您的意见,我了解您在使用服务时遇到异常。如果是这样,请确保在应用程序运行时WCF服务正在运行。

目标调用异常在某种意义上说,目标机器/服务/应用程序当前不可用。如果服务已停止,那么您的应用程序无法识别它,因此问题出现在图片中。

如果它能解决您的问题,请告诉我。
As per your comments i understand that you are getting exception while you are consuming the service. If it is so, please make sure that your WCF Service is running when your application is running.
Target Invocation exception in the sense, the target machine/service/application is currently unavailable. If the service has stopped, then your application is not able to identify it hence the issue came into the picture.
Let me know if it solves your problem.


这篇关于在Visual Studio中调试WCF服务时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆