最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Class Library (.NET Framework) AutoCAD DLL Reference Issue — CS0246 Errors - Stack Overflow

programmeradmin1浏览0评论

I'm trying to develop an AutoCAD plugin using the AutoCAD .NET API, but I'm facing a serious issue with DLL references. I'm constantly getting CS0246 and similar "type or namespace not found" errors, and I can't proceed further. I’d really appreciate help from anyone experienced in this area.

My goal: I want to dynamically manage block attribute data inside AutoCAD and build a custom rebar detailing system via .NET. I've been doing this for a long time using AutoLISP, but now I want to build a more stable and reliable system using .NET.

Environment:

AutoCAD Versions Tested: 2021, 2023, currently testing with 2017

Visual Studio: 2022 Community (latest version)

.NET Framework: 4.8

Platform Target: x64

Referenced DLLs:

acmgd.dll
acdbmgd.dll
(Referenced from: C:\Program Files\Autodesk\AutoCAD 2023)

Error:

CS0246: The type or namespace name 'CommandMethod' could not be found
CS0246: The type or namespace name 'Editor' could not be found
CS0246: The type or namespace name 'Document' could not be found
CS0117: 'Application' does not contain a definition for 'DocumentManager'

I suspect it's related to missing namespaces or improperly loaded DLLs, but I couldn't find a solid solution.

Any advice or working example setup would be greatly appreciated. Thanks in advance to anyone willing to help!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using System.Xml.Linq;

namespace DonatiOtomatik
{
    public class DonatiKomut
    {
        [CommandMethod("TESTKOMUT")]
        public void Yazdir()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.WriteMessage("\nMerhaba .NET dünyası!");
        }
    }
}

I'm trying to develop an AutoCAD plugin using the AutoCAD .NET API, but I'm facing a serious issue with DLL references. I'm constantly getting CS0246 and similar "type or namespace not found" errors, and I can't proceed further. I’d really appreciate help from anyone experienced in this area.

My goal: I want to dynamically manage block attribute data inside AutoCAD and build a custom rebar detailing system via .NET. I've been doing this for a long time using AutoLISP, but now I want to build a more stable and reliable system using .NET.

Environment:

AutoCAD Versions Tested: 2021, 2023, currently testing with 2017

Visual Studio: 2022 Community (latest version)

.NET Framework: 4.8

Platform Target: x64

Referenced DLLs:

acmgd.dll
acdbmgd.dll
(Referenced from: C:\Program Files\Autodesk\AutoCAD 2023)

Error:

CS0246: The type or namespace name 'CommandMethod' could not be found
CS0246: The type or namespace name 'Editor' could not be found
CS0246: The type or namespace name 'Document' could not be found
CS0117: 'Application' does not contain a definition for 'DocumentManager'

I suspect it's related to missing namespaces or improperly loaded DLLs, but I couldn't find a solid solution.

Any advice or working example setup would be greatly appreciated. Thanks in advance to anyone willing to help!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using System.Xml.Linq;

namespace DonatiOtomatik
{
    public class DonatiKomut
    {
        [CommandMethod("TESTKOMUT")]
        public void Yazdir()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.WriteMessage("\nMerhaba .NET dünyası!");
        }
    }
}
Share Improve this question edited 20 hours ago marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked 20 hours ago ozan aydemirozan aydemir 111 bronze badge New contributor ozan aydemir is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

I think you're missing a reference to the AcCoreMgd.dll

发布评论

评论列表(0)

  1. 暂无评论