-2

I have a WCF service which worked fine til today, an exception System.ServiceModel.FaultException was thrown, when i call a method of the this service.

 using (EService = new FaService.EServiceClient())
            {
                DataSet ds = EService.GetCompanies(3375); // exception here
                DataTable dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    Companies.Add(new Company() { Name = dr["c0"].ToString() });
                }
            }
Bilel Chaouadi
  • 31
  • 1
  • 1
  • 6
  • 2
    Did you even read the exception details? – ken2k Aug 05 '14 at 13:37
  • Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: Object reference not set to an instance of an object. Source Error: An unhandled exception was generated during the execution of the current web request. – Bilel Chaouadi Aug 05 '14 at 13:40
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – nvoigt Aug 05 '14 at 13:45

1 Answers1

3

In a service, the FaultException class is used to create an untyped fault to return to the client for debugging purposes. It really handles generic or "unknown" faults in a process in the program/client. You can pinpoint the error down to a line and typically can just debug your system/program/client to find where this "unknown" error is occurring. It may be helpful to post this method's code in which you are having issues, but as for your post thus far, I would debug your program and step line by line to make sure there isn't any unnecessary lines of code.

Reference: http://msdn.microsoft.com/en-us/library/system.servicemodel.faultexception(v=vs.110).aspx

Adam
  • 2,327
  • 16
  • 28
  • @Bilel I don't have the reputation yet to comment on anything other than my own posts, but follow the stack trace to the source of your problems. It will lead to the class of the problem, to the method, to the exact line and often to the exact call of the issue. Follow your stack trace and use your simple debugging techniques. – Adam Aug 05 '14 at 13:43
  • i can not do the dubg step by step beacuse the method is in the wcf service – Bilel Chaouadi Aug 05 '14 at 13:50
  • http://msdn.microsoft.com/en-us/library/bb514135.aspx – Adam Aug 05 '14 at 13:51