title: Getting System.BadImageFormatException Error while Running the .Net Program in x64 Server
body: <p>I have an old DotNet Program compiled in 32 Bit, which has a Form to load and execute SSIS package. For Executing SSI Package it uses the Assembly Microsoft.SqlServer.DTSRuntimeWrap which is present in 32 Bit as displayed below.</p>
  
  <pre><code>using Microsoft.SqlServer.Dts.Runtime.Wrapper;
  .
  .
  namespace WinFmAppETLControl
  {
    public class FrmControl : Form
    {
  
          this.ProcessStep1();
  
          private void ProcessStep1()
           {
           if (((IDTSApplication100)new ApplicationClass()).LoadPackage("C:\\Users\\abc\\MyData\\WinFmAppETLControl\\ETL\\SUN Daily ETL\\Batch and SysidRange.dtsx", true, (IDTSEvents100)null).Execute() == DTSExecResult.DTSER_SUCCESS){
  
          MessageBox.Show("Success");
          }
          else{
          MessageBox.Show("Failure");
          }
      }
    }
  }
  </code></pre>
  
  <p>Now i need to Migrate this program to 64 Bit new Server. I Create the exe file to run in the server.
  When i build the project in x64 and run on server, i am getting below error while executing the exe file.</p>
  
  <blockquote>
    <p>Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap, 
    Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or 
    one of  its dependencies. An attempt was made to load a  program with 
    an incorrect format.</p>
  </blockquote>
  
  <p>When i build the project in x86 and run on server,  i am getting below error while executing the exe file.</p>
  
  <blockquote>
    <p>System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {BA785E28-3D7B-47AE-A4F9-4784F61B598A} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).</p>
  </blockquote>
  
  <p>The SSIS running on server is x64 bit (D:\Program Files\Microsoft SQL Server\110\DTS\Binn\MsDtsSrvr.exe").</p>
  
  <p>I checked many answers but couldn't find the solution. I am relatively new to .Net </p>