There is a way to prevent "Object reference not set to an instance of an object"?

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
Sometimes our projects start to crash, and a lot of crash with this error, there is a way to catch it and stop?

Executing action CSharp OwnCode: Captura Traffic.id: 5db30c16-c377-4173-8a6a-e96a05c62a26 Object reference not set to an instance of an object.

We already have a code to resstart instance, clear cache, clear cookies, and another things and there is no way to avoid it.

Anyone have problems like that and have a solution for it?
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 767
Благодарностей
2 414
Баллы
113
In your code, before using any object, check if it exists.
C#:
if(Traffic.id != null) {
// your code
}
 
  • Спасибо
Реакции: EtaLasquera

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
We will try! Thank you!
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
  • Спасибо
Реакции: BAZAg

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)