title: How To Connect C# with ACAD 2010
body: <p>Work on vs2008 C#, Need help to connect with autocad 2010, I follow the following steps to connect but it gives me an error. </p>
  
  <p>I have to add a reference, so I go to references>>add reference>>[COM TAB]>>Autocad 2010 type library>>[OK]</p>
  
  <p>I use two libraries:</p>
  
  <pre><code>using Autodesk.AutoCAD.Interop;
  using Autodesk.AutoCAD.Interop.Common;
  </code></pre>
  
  <p>And then I use the following code to connect with AutoCAD 2010:</p>
  
  <pre><code>namespace Sample_CSharp_Acad_connect
  {
  
  
   class Program
      {
          private static IAcadApplication oAcadApp = null;
          private static string sAcadID = "AutoCAD.Application.18";
  
          static void Main()
          {
              try  //get a running AutoCAD instance if avaialbale
              {
                  oAcadApp = (IAcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(sAcadID);
              }
              catch(Exception) //none found so start a new instance
              {
                  System.Type AcadProg = System.Type.GetTypeFromProgID(sAcadID);
                  oAcadApp = (IAcadApplication)System.Activator.CreateInstance(AcadProg);
              }
              if (oAcadApp != null)
              {
                  oAcadApp.Visible = true; //could leave this false to hide Acad from the user
                  //do whatever with Acad
                  //oAcadApp.Quit();
              }
          }
      }
  </code></pre>
  
  <p>Error message : <strong>error in getting object class COM for component CLSID</strong>
  <img src="https://i.stack.imgur.com/hiY5j.png" alt="enter image description here"></p>