Hi,
There is an exception being thrown and the message is visible during development in Debug mode.
DisplayConduit
System.NullReferenceException: Object reference not set to an instance of an object.
at Rhino.Display.DisplayConduit.PassesFilter(DrawEventArgs e)
at Rhino.Display.DisplayConduit.ExecConduit(IntPtr pPipeline, UInt32 conduitSerialNumber, UInt32 channel)
Tracing the error, it leads me to the decompiled code in abstract DisplayConduit class:
public abstract class DisplayConduit
{
...
private bool PassesFilter(DrawEventArgs e)
{
...
if (e.Viewport.ViewportType == ViewportType.PageViewMainViewport)
{
return SpaceFilter == ActiveSpace.PageSpace;
}
return SpaceFilter == ActiveSpace.ModelSpace;
}
...
}
The error is thrown when the NamedViews panel is open, named views are being refreshed and custom conduit DisplayConduit.SpaceFilter is set to anything other than None
.
What I have observed is that the Viewport
property is not always defined in a DrawEventArgs
instance and can sometimes be null
, thus throwing this exception. Is this intended ?
The message is very annoying and its occurrence multiplies as the number of NamedViews increases and refreshes after every command.
I’ve spent quite sometimes cracking this down and now my plugin is full of null
checks! which is a good thing! So for anyone implementing custom display conduit, hope it help!