Click here to Skip to main content
14,696,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 28: {
Line 29:
Line 30:
CDT = Cadapter.SELECT_SEARCH_COMPANY(Session["JOBCATE"].ToString(), Session["QUALI"].ToString(), Session["skill"].ToString());
Line 31: Session["cid"] = CDT.Rows[0]["CID"].ToString();
Line 32: if (CDT.Rows.Count == 0)

What I have tried:

CDT = Cadapter.SELECT_SEARCH_COMPANY(Session["JOBCATE"].ToString(), Session["QUALI"].ToString(), Session["skill"].ToString());
Line 31:             Session["cid"] = CDT.Rows[0]["CID"].ToString();
Line 32:             if (CDT.Rows.Count == 0)
Posted
Updated 24-Jan-20 3:04am

one of your session variable is not set previously.

Or cadapter is not instantiated;

for example to instantiate string code-( string s =new string())

It will throw an exception.
   
Comments
sommr0 22-Jul-17 4:20am
   
How to Fix It?
kp564 22-Jul-17 4:27am
   
can you share you exception screenshot?

and what is cadaptar?
sommr0 22-Jul-17 5:41am
   
Here how to post snapshot? can you contact me through email? amjad.sommro12@gmail.com
kp564 24-Jul-17 1:50am
   
hope works all fine.
if yes accept it as answer.
Something in the code is null at runtime and you try to invoke a method on it, like a call to ToString() for example. If you run using a debugger it will tell you exactly what it is. You can also easily use a watch to check the values. Just hover over the variables to see the values when the debugger paused execution to show you the exception using any IDE (visual studio, xamarin, monodevelop, rider).

Good luck!

PS. Check out on the web how to do effective debugging.
   
The simple solution could be to enable the exception types from exception assistant so that your program execution will halt when you are debugging (no need to debug every line). After you enabled the exceptions, the execution will halt on the line which is throwing null reference error.

To enable exceptions:

VS2015: Debug -> Windows -> Exception Settings.

If you are using other version of VS just google find the menu option.
   
Very dangerous in an ASP.NET app to assume there will be data. A good way to quickly crash your website!

I can see two lines where the error may occur. Also, the first line has multiple possible opportunities for the error to occur.

As mentioned above, it is time to break out the debugger, roll up the sleeves, and do some sleuth work. If you are not familiar with debugging, then here is a great place to start: Basic Debugging with Visual Studio 2010 - YouTube[^]
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



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