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

501 Views Asked by At

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

2

There are 2 best solutions below

5
Eli On BEST ANSWER

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.

1
Roshni Gandhi On

Your connection string must be null. Go to your Webconfig file which is in xml format. Check whether tag has the proper connection string or it is missing. If it is missing you can add it by using this:

<connectionString>
<add name="connection_name" providerName = "provider_name" connectionString="connectionString"/>
</connectionString>

Try this it will work.