title: How to use .dll 32bit run on Excel 64bit VSTO C#
body: <p>I have 2 projects in a solution :One is Console Project where communicate with PLC and another is Excel add-in project.</p>
  
  <p>My Problem: using .dll (x32bit) and run on Excel 64bit. Control button by Ribbon button to connect or disconnect to PLC. So, I added Excel add-in project in Console Project's references  to use Excel add-in public class. But, i cannot call constructor of VSTO Addin</p>
  
  <pre><code>public ThisAddIn(global::Microsoft.Office.Tools.Word.ApplicationFactory factory, global::System.IServiceProvider serviceProvider) : 
                  base(factory, serviceProvider, "AddIn", "ThisAddIn") {
              Globals.Factory = factory;
          }
  </code></pre>
  
  <p>Here my code in Console:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  //using Microsoft.Office.Tools.Ribbon;
  using PLC2EXCEL_Addin;
  using DATABUILDERAXLibLB;
  using Microsoft.Office.Tools.Ribbon;
  using System.Runtime.InteropServices;
  using Microsoft.Office.Core;
  using Microsoft.Office.Interop.Excel;
  
  namespace PLC2EXCEL
  {
      class Program
      {
          public static DBCommManager dBCommManager = new DBCommManager();
  
          static void Main(string[] args)
          {
  
              dBCommManager.PLC=DBPlcId.DBPLC_KV3000;
              dBCommManager.Peer = "USB";
              //Microsoft.Office.Tools.Excel.ApplicationFactory _fatory ;
              //_fatory.GetRibbonFactory();
  
              //ThisAddIn thisAddIn = new ThisAddIn(Microsoft.Office.Tools.Excel.ApplicationFactory,IServerProvider); //i am not sure about this
  
              PLC2EXCEL_Ribbon pLC2EXCEL_Ribbon = new PLC2EXCEL_Ribbon();
              if (pLC2EXCEL_Ribbon != null)
                  pLC2EXCEL_Ribbon.connectPLC_btn.Click += new RibbonControlEventHandler(startPLC2Excel);
              dBCommManager.Connect();
              Console.WriteLine("Connect PLC OK");
              Console.ReadLine();
          }
  
          public event EventHandler startPLC2Excel1;
          public static void startPLC2Excel(object sender, RibbonControlEventArgs eventArgs)
          {
              //DATABUILDERAXLibLB.DBCommManager dBCommManager = new DBCommManager();
              //dBCommManager.PLC = DBPlcId.DBPLC_KV3000;
              //dBCommManager.Peer = "USB";
              dBCommManager.Connect();
              Console.WriteLine("Connect PLC OK");
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>And code in Ribbon of Excel Addin:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.InteropServices;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.Office.Tools.Ribbon;
  
  namespace PLC2EXCEL_Addin
  {
      public partial class PLC2EXCEL_Ribbon
      {
          private void PLC2EXCEL_Ribbon_Load(object sender, RibbonUIEventArgs e)
          {
  
          }
  
  
          [ComVisible(true)]
          public void connectPLC_btn_Click(object sender, RibbonControlEventArgs e)  //How to catch this event from Console project
          {
  
              //Catch event 
              MessageBox.Show("Connect to PLC");
  
          }
          public void abc() { }
      }
  }
  </code></pre>
  
  <p>Sorry any inconvenience, this is my first post.
  Thank in advance.</p>