Null check for safer interop with C#.