R
R
Roman Rakzin2016-10-22 22:48:46
WPF
Roman Rakzin, 2016-10-22 22:48:46

Object reference not set to an instance of an object. Why? If the values ​​are not empty?

I send data to the server. They are not empty. I receive a response from the server and after 1-2 seconds I get the exception Object reference not set to an instance of an object.
What am I doing wrong? And from what it arises, if the data is not empty, as far as I understand?
a71077a4a7b14ba3bba660993394f4b0.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Rakzin, 2016-10-22
@TwoRS

If you replace it with this code, it works

string strValue = lstbox.SelectedValue as string;
string MyValue= listBoxfilesAndDirectoriesInServerList.SelectedValue.ToString() ;
MessageBox.Show(MyValue);

S
Sanostee, 2016-10-23
@andrewpianykh

Add a check

if(listBoxfilesAndDirectoriesInServerList.SelectedValue != null)
{
   //....
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question