Thursday, February 9, 2017

C# WCF Tips: Fix error “object reference is not set to an instance object” while adding WCF service reference

When we adding service reference to project sometimes we encounter “object reference is not set to an instance object” error. Sometimes it fix after follow following steps.


Step 1: Check are there any errors in WCF service and if there were errors fix it and retry.

Step 2: If there were existing service reference then delete it and add again. 

Step 3: If step 2 not success then delete reference from service reference folder in project location (from hard disc) and try to add reference again.

Step 4: If first three steps not working go to the app config or web config file and remove relevant endpoint settings and try to add again.

Step 5: Host WCF service in iis and add service reference from iis url