Search code examples
c#.netwcfwcfserviceclient

'System.NullReferenceException' occurred in databaseService.dll in wcf service


I made a WCF service and hosted in windows forms application and made a client win from application to consume that I service retrieves data from database and shows to the client by entering ID.

How can I solve it?

I have seen many null references questions in stack overflow but thy are not related to WCF.

Image of error in my code:

image of error in my code and code

Connection string in my web.config file:

this is connection string in my web.config file


Solution

  • You must verify that the executable that is actually running the service also has the connection string defined in app.config or web.config. Probably, when you test it you have it defined correctly, but when you run it outside the tester, the application that is actually running does not have it defined.