Connect Autocad to Smartsheet data using c#

Connect Autocad to Smartsheet data using c#

dwattersQJ39E
Participant Participant
484 Views
5 Replies
Message 1 of 6

Connect Autocad to Smartsheet data using c#

dwattersQJ39E
Participant
Participant

Hello, 

I am attempting to connect to a smartsheet using their API in a C# program for autocad / autocadMap3d. 
i am getting the error : "could not load file or assembly 'smartsheet-csharp-sdk' or one of its dependencies. 

System.IO.FileNotFoundException: Could not load file or assembly 'smartsheet-csharp-sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'smartsheet-csharp-sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null'

I have installed the smartsheet sdk via NuGet, not sure what i am missing? 

     public static void InitializeSmartsheetClient()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            string smartsheetAccessToken = ""; // token
            long specificSheetId = ;  // Smartsheet Tracker 


            try
            {

                // Initialize Smartsheet client with the API access token using SmartsheetBuilder
                var smartsheetClient = new SmartsheetBuilder()
                                 .SetAccessToken(smartsheetAccessToken)
                                 .Build(); // This initializes the SmartsheetClient

                // Retrieve the sheet by its ID from Smartsheet
                var sheet = smartsheetClient.SheetResources.GetSheet(specificSheetId, null, null);  // Retrieve the sheet by ID

                // If the sheet is retrieved successfully, display the sheet name
                ed.WriteMessage($"\nConnected to Smartsheet! Sheet Name: {sheet.Name}\n");
            }
            catch (System.Exception ex)
            {
                // If there’s an error connecting to Smartsheet, display the error message
                ed.WriteMessage($"\nError connecting to Smartsheet: {ex.Message}\n");
            }
        }
0 Likes
Accepted solutions (1)
485 Views
5 Replies
Replies (5)
Message 2 of 6

norman.yuan
Mentor
Mentor

You did not provide important information: What version of AutoCAD you use, AutoCAD 2025, or older versions of AutoCAD?

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 6

dwattersQJ39E
Participant
Participant

I am on 2025. 
with doing more digging, I am investigating issues related to .net framework miss matches. the NuGet installer for Smartsheet was installing a version that's targeted to 8.0, I am cloning a version for 4.5.2 in hopes that that fixes the issue. 
I've come to learn that AutoCAD doesnt support .net past 4.8? 

0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor

You must use .NET 8 with AutoCAD 2025 .NET API development.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

dwattersQJ39E
Participant
Participant

sorry, I'm on 2024. I am upgrading to 2025 now. 
you think that framework issue was likely the problem? 

thank you for the help! 

0 Likes
Message 6 of 6

norman.yuan
Mentor
Mentor
Accepted solution

Since Smartsheet-C#-sdk requires .NET 8, while pre-2024 AutoCAD versions use .NET Framework, so you cannot mix them together. If you target Acad2024 or older, you may want to try older version of SmartSheet Nuget package, such as SmartSheet.NET.Standard, which requires .NETStandard 2.0, which can be used with .NET Framework 4.5/.6/.7/.8. If you target AutoCAD 2025 (requiring .NET 8), then SmartSheet C# SDK should work. I did a quick test with my Acad2025, and yes, the smartsheet-csharp-sdk.dll is loaded without issue.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes