Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to port a project to 2025 / .net 8.0. It isn't working and as a sanity check ive created the "first autocad project" As per the .net 2025 guide.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[assembly: CommandClass(typeof(MyFirstProject1.Class1))]
namespace MyFirstProject1
{
public class Class1
{
[CommandMethod("AdskGreeting")]
public void AdskGreeting()
{
// Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Starts a new transaction with the Transaction Manager
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 write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
/* Creates a new MText object and assigns it a location,
text value and text style */
using (MText objText = new MText())
{
// Specify the insertion point of the MText object
objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);
// Set the text string for the MText object
objText.Contents = "Greetings, Welcome to AutoCAD .NET";
// Set the text style for the MText object
objText.TextStyleId = acCurDb.Textstyle;
// Appends the new MText object to model space
acBlkTblRec.AppendEntity(objText);
// Appends to new MText object to the active transaction
acTrans.AddNewlyCreatedDBObject(objText, true);
}
// Saves the changes to the database and closes the transaction
acTrans.Commit();
}
}
}
}
Having issues with the reference files, I've downloaded from here:
AutoCAD ObjectARX SDK downloads | Autodesk Platform Services
Also tried using the same dll files from autocad civil3d installation and both are giving errors:
Severity Code Description Project File Line Suppression State
Error (active) CS0103 The name 'Application' does not exist in the current context testclass "my path" - Documents\Code\net8 tester\testclass\Class1.cs 20
When I compile it complains that bout different versions of microsoft.visualbasic? I'm not using visual basic?!
Severity Code Description Project File Line Suppression State
Warning (active) MSB3277 Found conflicts between different versions of "Microsoft.VisualBasic" that could not be resolved.
There was a conflict between "Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.VisualBasic, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.VisualBasic, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\Microsoft.VisualBasic.dll].
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\Microsoft.VisualBasic.dll
Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\Microsoft.VisualBasic.dll".
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref/net8.0/Microsoft.VisualBasic.dll
References which depend on or have been unified to "Microsoft.VisualBasic, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
C:\Program Files\Autodesk\AutoCAD 2025\accoremgd.dll
Project file item includes which caused reference "C:\Program Files\Autodesk\AutoCAD 2025\accoremgd.dll".
accoremgd
C:\Program Files\Autodesk\AutoCAD 2025\acdbmgd.dll
Project file item includes which caused reference "C:\Program Files\Autodesk\AutoCAD 2025\acdbmgd.dll".
Acdbmgd
accoremgd
AeccDbMgd
C:\Program Files\Autodesk\AutoCAD 2025\C3D\AeccDbMgd.dll
Project file item includes which caused reference "C:\Program Files\Autodesk\AutoCAD 2025\C3D\AeccDbMgd.dll".
AeccDbMgd
C:\Program Files\Autodesk\AutoCAD 2025\C3D\AeccHydroCalcsMgd.dll
Project file item includes which caused reference "C:\Program Files\Autodesk\AutoCAD 2025\C3D\AeccHydroCalcsMgd.dll".
AeccDbMgd testclass C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 2401
Tried using the nuget for the autocad references but it doesnt work, compiles fine but when I load it to a drawing none of the commands show up.
Anyone know whats up?
Solved! Go to Solution.