Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
getting Error "Object reference not set to an instance of an object" at this line while creating WCFService and LINQ..

C#
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["MySampleDBConnectionString1"].ConnectionString, mappingSource)
Posted
Updated 22-Feb-15 6:16am
v2

The likeliest reason is that you don't have a connection string named MySampleDBConnectionString1 in your config file.
 
Share this answer
 
Comments
chetna2810 22-Feb-15 12:20pm    
yes it is in my config file..
chetna2810 22-Feb-15 12:31pm    
Yes Got it i don't create connection string on client another config..Thanks
Now it is working
Wendelius 22-Feb-15 14:04pm    
Glad it worked out
That is because either of your parameters are null. For me, the second parameter has a more chance of being null; because usually you've already filled the ConnectionString property, or either of it, the connection string is not available.

So, if you're using Visual Studio, debug the code having a breakpoint set at this position. Then once your code reaches this location, you will see which of the cases is true; which variable is null in your code. Then you can (above that particular line of invoking the base-class's constructor) set the value to a non-null value to minimize this problem.

Remember, WCF also runs over .NET framework, so an error that it would throw would be easily handled as all other .NET exceptions. NullReferenceException[^] is an exception of .NET framework, and beginners always fall for it as it is a bit tricky to find which object threw this, and why it was thrown. Good luck.
 
Share this answer
 
v2

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