The root cause problem of this type of error is, you are trying to access null reference in that case you may face this type of error. Before access the value check the condition whether object contains value or not. If not then skip the assignment else assign value.

EX:

if(value!=null) //assign value

To analyse the issue in your code blocks better to debug the program then only you can get where it's get strucked or refer stack trace for more details.

Hope this will helpful to you...--------------------------------------------------------------------------------Give respect to your work, Instead of trying to impress your boss.

Hai Danya,This is very common error which you will get when the object is null and you are trying to convert it to some other type. So before converting, first you need to check whether the object is having value or not.There is a small issue in your code at the below line:

var btout = new Bitmap(_bt.Width, _bt.Height);

Rest all is well. I just formatted your code as per the coding standards. Please follow the below: