See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: c# DLL to be referenced in Excel doesn't work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2019-08
    Posts
    4
    Login to Give a bone
    0

    Default c# DLL to be referenced in Excel doesn't work

    Hello,

    I'm trying to get the Excel communicate to Autocad using a DLL but it won't work.
    The DLL references fine in Excel, all the COM bits are ticked, the C# project has the references to the correct Autocad libraries (it compiles fine), I can call a simple test function in it but it fails when the Autocad object is called with the error :

    Run-time error '-2146233036 (80131534)': Automation error

    Help please !


    Code:
    using System.Collections.Generic;
    using System.Runtime.InteropServices;
    using System.Linq;
    using Autodesk.AutoCAD.DatabaseServices;
    using Autodesk.AutoCAD.Runtime;
    using CadApp = Autodesk.AutoCAD.ApplicationServices.Application;
    using Autodesk.AutoCAD.ApplicationServices;
    
    [assembly: CommandClass(typeof(AutocadHandler.MyCommands))]
    
    namespace AutocadHandler
    {
        [ClassInterface(ClassInterfaceType.AutoDual)]
    
    
        public class MyCommands
        {
            public static void TestFunction()
            {                       
                string strFileName = "C:\\Users\\CORE I7\\Documents\\Drawing2XLS.dwg";
                var acDocMgr = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager;
                acDocMgr.Open(strFileName, false);
                acDocMgr.MdiActiveDocument.Editor.WriteMessage("Hello Excel");
            }
        }
    }
    Last edited by BlackBox; 2019-08-07 at 01:16 PM. Reason: Please use [CODE] Tags

Similar Threads

  1. Autocad doesn't load DLL into memory until the execution
    By samideqlqpart350559 in forum Dot Net API
    Replies: 1
    Last Post: 2017-08-04, 01:41 PM
  2. Replies: 3
    Last Post: 2014-09-16, 11:34 AM
  3. Replies: 4
    Last Post: 2014-09-12, 05:31 PM
  4. DLL plugin worked at first but now doesn't
    By rollinkuhn in forum Dot Net API
    Replies: 1
    Last Post: 2011-01-27, 08:44 PM
  5. Problème chargement dll "myrevittools.dll"
    By kaartoum in forum Revit - API
    Replies: 1
    Last Post: 2008-10-01, 06:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •