Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a simple wpf application for binding data in datagrid. It throws error while running at following line.

string ConString = System.Configuration.ConfigurationManager
.ConnectionStrings["ConString"].ToString();
Exception shows: Exception has been thrown by the target of an invocation."

InnerException:{"Object reference not set to an instance of an object."}
Posted

1 solution

.ConnectionStrings["ConString"] seems to be null.
When you use ToString() over a null you get this error.

Check if you have passed in the right argument and that there are values inside ConnectionStrings.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900