Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9205827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:03:03+00:00 2026-06-18T00:03:03+00:00

I created a webservice that returnes some categories from database. If i test with

  • 0

I created a webservice that returnes some categories from database. If i test with the client that WCF is offering everything is perfect.
I started building a client. I added a service reference to my service http://localhost/Transaction/transaction.svc. I create a new instance of the client webservice

  TransactionClient tc = new TransactionClient("BasicHttpEndpoint");
 Category[] availableCategories = tc.GetAllCategories();

I get Object reference not set to an instance of an object on the second line of code. The endpoint name is correct.

Any idea why the error ?

PS : if you need more code please let me know what to post.
Thanks in advance.

Edit :

  [OperationContract]
  List<Category> GetAllCategories();

  Implementation : 
  public List<Category> GetAllCategories()
   { return db.GetAllCategories()}

The service is working is i test with WCFClient, so the rest of my code must be corect.

This is the code that gets me the items from database. I try with the solution posted but the app did not stop.

List<Category> response = new List<Category>();
            connect();

            SqlCommand cmd = new SqlCommand("select id_category, name from tbl_category", conn);
            try
            {
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Category new_category = new Category();
                    new_category.id_category = int.Parse(dr["id_category"].ToString());
                    new_category.name = dr["name"].ToString();
                    response.Add(new_category);
                }

            }
            catch (SqlException ex)
            {
                Console.Out.Write(ex.ToString());
            }
            finally
            {
                dr.Close();
                conn.Close();
            }

            return response;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:03:06+00:00Added an answer on June 18, 2026 at 12:03 am

    FaultException is exception transfered from other side of WCF channel. Meaning, that exception did not happen on line you call tc.GetAllCategories();, but on server side, in processing of that method.

    FaultException wraps exception which occurred on server side. From what we can see in what you pasted, it’s NullReferenceException. To find exact place where it occurs, set breakpoint in GetAllCategories method and step through it until it fails. Since this is a WCF service, exception in handling method call does not crash the service, but wraps the exception and sends it back to client.

    Another way to find where error occurs would be to debug service, open Debug -> Exceptions in Visual Studio and tick check box in Thrown column next to Common Language Runtime Exceptions. This tells VS debugger to stop execution when error occurs, even though exception will be caught by WCF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a small web service that returns some json, and the returned json
I have created one application in flex that is accessing the Java webservice using
I have created a function in PHP that calls a webservice and parses through
I'm working with some web services that have already been created and I need
I’ve created a winform application that communicates with a WCF service. The winform displays
I am trying to write some JavaScript that calls a Web Service I've created.
I've created a client for SOAP web service, but in the generated code some
I have some written a number of unit tests that test a wrapper around
I need to create a web service that returns XML data to some of
I've created a web service that uses a generic type Response<TCode, TData> and so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.