Руководство Autodesk, проект два, пространство имен не может напрямую содержать элементы из [дубликата]

Я использую эти разработчики Руководство, которое я нашел для AutoCAD .NET и скопировал пример на странице 67, однако я получаю сообщение об ошибке «Пространство имен не может напрямую содержать элементы, такие как поля или методы» в этой строке:

public static void ListEntities()

Это код, который у меня есть в Visual Studio:

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;

[CommandMethod("ListEntities")]

public static void ListEntities()

{  // Get the current document and database, and start a transaction 
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
    Database acCurDb = acDoc.Database;
    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
    {      // Open the Block table record for read      
        BlockTable acBlkTbl;
        acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
        // Open the Block table record Model space for read      
        BlockTableRecord acBlkTblRec;
        acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
            OpenMode.ForRead) as BlockTableRecord;
        int nCnt = 0;
        acDoc.Editor.WriteMessage("\nModel space objects: ");
        // Step through each object in Model space and      
        // display the type of object found      
        foreach (ObjectId acObjId in acBlkTblRec)      
        { acDoc.Editor.WriteMessage("\n" + acObjId.ObjectClass.DxfName);
        nCnt = nCnt + 1;
    }
        // If no objects are found then display a message      
        if (nCnt == 0)      {
    acDoc.Editor.WriteMessage("\n No objects found");
}
        // Dispose of the transaction
    }
}

У меня есть ссылки на решение Accoremgd.dll, acdbmgd.dll и acmgd.dll.


person Daniel Gilliland    schedule 24.07.2017    source источник
comment
Поместите класс вокруг вашего метода   -  person Ben    schedule 24.07.2017
comment
Спасибо, это работает Бен   -  person Daniel Gilliland    schedule 27.07.2017