Entity Selection in hidden mode

I am trying to test out the API for Draftsight. I have written a small test application that opens up a .dwg and selects entities using entity filter. It runs beautifully until I set visible=false. Any advise on how I go about this?

------------------------------------------------------------------------------------------

DraftSight.Application dApp;

Document dsDoc;

Model dsModel;

SketchManager dsSM;

LayerManager dsLM;

dApp = new DraftSight.Application();

dApp.Visible = true;

// dApp.Visible = false // this creates issues

dsDoc = dApp.OpenDocument(@"C:\\temp\\test.dwg", dsDocumentOpenOption_e.dsDocumentOpen_Default);

dsModel = dsDoc.GetModel();

dsSM = dsModel.GetSketchManager();

dsLM = dsDoc.GetLayerManager();

SelectionFilter selFilt = dsDoc.GetSelectionManager().GetSelectionFilter(); // This is where the error happens Null exception.

// SelectionFilter selFilt = new SelectionFilter(); // This one also fails.

selFilt.AddEntityType(dsObjectType_e.dsNoteType);

selFilt.AddEntityType(dsObjectType_e.dsSimpleNoteType);

selFilt.Active = true;

 

-----------------------------------------------------------------------------------