Click here to Skip to main content
15,885,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello ,

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

C#
[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

SQL
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;
           }
       }


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
Posted
Comments
Member 7895843 22-Jul-14 3:38am    
hi

i tried creating the same service but it didnt give me any exception. can u just give any more details like when you are facing the error.
SaadZulfiqar 22-Jul-14 3:40am    
As soon as i debug to get the url to be used my MVC project..
Member 7895843 22-Jul-14 3:46am    
ok but i am not getting any error..i am able to execute all methods.if i get any soln i willpost it.

1 solution

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.
 
Share this answer
 
Comments
SaadZulfiqar 22-Jul-14 8:42am    
Well , no .. apart from my client application .. i have created my WCF service , when i debug it exception is raised , without any amendments made if i clean and rebuild the solution and than debug it , it works fine .. i dont know why it happens ... ??
Kumarbs 22-Jul-14 8:46am    
You mean the application and the service is same?
SaadZulfiqar 22-Jul-14 8:49am    
nops , my application is asp.net mvc and its not the same as my wcf service ..
Kumarbs 22-Jul-14 8:58am    
Exactly, your WCF Service has stopped when you were debugging, hence the issue was. Try to reproduce this by stopping the Service.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900