GrasshopperDocument in VS

hi everyOne

using System.Collections;
using System.Collections.Generic;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
using System.Linq;
  private void RunScript(ref object A)
    A = from o in GrasshopperDocument.Objects where o.Attributes.Selected
        select o.NickName + " (" + o.Name + ") | " + o.Category + " > " + o.SubCategory;

if i use GrasshopperDocumen in this code in vs ? whats is GrasshopperDocument?
i use:
But it doesn’t work!

“Instances.ActiveCanvas.Document” should give you the Grassshopper Document instance of the currently active canvas (The GUI element where it draws to). But be aware of the situation that your plugin can execute code when no active canvas is present. E.g. when being loaded. Also be aware of the possibility that while code is running and pointing to a document, the user might switch the active canvas, by simply loading another document. If you cache it, then this can then lead to weird behavior. If you provide the correct code, we might help you better.

You can also use DnSpy and debug the full Grasshopper code. Then you see exactly what you do wrong.