Hi, I even don't know where to begin, but you got all this wrong.
If you handle a pcb document, you need to use the MGCPCB.Document class. The MGCPCB.Command is unrelated of any of your code.
Also you have run licensing ritual by using MGCPCBAutomationLicensing.Application class. You have to create a token by the licensing application and you have to validate your pcb document by this token.
I don't have the exact codes right now, but it should be like this:
MGCPCB.Document pcbDoc = pcbApp.ActiveDocument;
MGCPCBAutomationLicensing.Application _licApp = new MGCPCBAutomationLicensing.Application();
int key = pcbDoc.Validate(0);
int token = _licApp.GetToken(key);
pcbDoc.Validate(token);
if(pcbDoc.IsValid())
{
//Do something right here
}
Also, I strongly encrouge you to define your Document hooks after the validation ritual.
Edit: Before I forget, If you don't know how to define pcbApp, it can be MGCPCB.Application or MGCPCB.ExpeditionPCBApplication.
You can connect the exact applicaton with Marshal.GetActiveObject("MGCPCB.ExpeditionPCBApplication") or by using ROT (Running object Table)