Items with no label
3335 Discussions

How do I avoid getting a 'System.NullReferenceException' when using STREAM_TYPE_DEPTH in C#?

tross3
Beginner
990 Views

I am using C#, STREAM_TYPE_COLOR works fine, and I can see an image, but when I try to use STREAM_TYPE_DEPTH it crashes and tells me it is null. Also, the infrared light does not come on. It is not a problem with the camera though because the depth works fine in the Realsense Viewer program.

0 Kudos
1 Solution
MartyG
Honored Contributor III
192 Views

With a NullReferenceException, I would typically expect it to be related to a reference that is being called but its location has not been defined.

 

For example, I might ask a program for the value of a variable called MartysNumber, but if I have not told my program where the variable can be found then a NullReferenceException may occur.

 

It is most likely to occur if the reference being called is stored in a different script. ​

View solution in original post

0 Kudos
3 Replies
MartyG
Honored Contributor III
192 Views

Are you using Unity and the RealSense Unity Wrapper for your project, please?

0 Kudos
tross3
Beginner
192 Views

Thanks for the response. No, I'm not Unity, just C# and the C# wrapper.

0 Kudos
MartyG
Honored Contributor III
193 Views

With a NullReferenceException, I would typically expect it to be related to a reference that is being called but its location has not been defined.

 

For example, I might ask a program for the value of a variable called MartysNumber, but if I have not told my program where the variable can be found then a NullReferenceException may occur.

 

It is most likely to occur if the reference being called is stored in a different script. ​

0 Kudos
Reply