本人经过调试:“未将对象引用设置到对象的实例”错误所在位置: blkRef.CreateExtensionDictionary();、//出错地点blkRef=null
[CommandMethod("z")]
        public void kzzd()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage ("创建对象扩展词典\n");
           PromptEntityOptions ppe = new PromptEntityOptions("选择对象:\n");
           PromptEntityResult ref2=ed.GetEntity (ppe );
           if (ref2.Status != PromptStatus.OK)
           {
               ed.WriteMessage("选择对象失败,退出");
               return;
           }
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                DBObject obj = trans.GetObject(ref2.ObjectId, OpenMode.ForWrite) as DBObject;
                BlockReference blkRef;
                if (!(obj is BlockReference))
                {
                    blkRef = obj as BlockReference;
                }
                else
                {
                    return;
                }
                blkRef.CreateExtensionDictionary();、//出错地点blkRef=null
                DBDictionary extensionDict = (DBDictionary)trans.GetObject(blkRef.ExtensionDictionary, OpenMode.ForWrite,false);
                
            }
        }