I created a WCF service (.NET 3.5) that grabs data from a db and returns a list of objects. It works just fine. I tested it using the WCFTestClient application and got the desired results.
Now, I tried to create an ASP.NET web application and consume the service. After enabling <serviceDebug includeExceptionDetailInFaults="true"/> in the config file, the error message is “Object reference not set to an instance of an object.”
How do I modify the service to work with ASP.NET?
Thanks!
Update 1 – I created a reference to the service. When I ran my very basic testing app, based on the sample code displayed on the service’s default web page, I got the “Object reference not set to an instance of an object” message.
The service is returning the correct results when I use the WCF Test Client utility provided with Visual Studio. When I try to use the following code, all in the page_load event, I get the object reference message.
PhoneNumberServiceClient client = new PhoneNumberServiceClient();
// Use the 'client' variable to call operations on the service
List<PhoneNumber> phones = client.GetPhoneNumbers();
// Always close the client.
client.Close();
I will try to get some additional debug info.
Have you tried openning the service after you initialize it by using:
If the problem still persists maybe the it lies on the WCF method itself. Try to add breakpoints on your method and debug it to trace the cause of the error. You could also use profilers.