2
votes

I made a SSIS package that would export data to msaccess. If i try to run the package on its solution project it will execute without error. But when I call the package inside my program, I will get an error

Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'. This assembly was compiled for a different processor.

Here is my code:

public void RunPackage()
    {
        textstring("Locating Package...");
        m_worker2.ReportProgress(20);
        string PkgLocation;
        Package pkg;
        Microsoft.SqlServer.Dts.Runtime.Application _app = new Microsoft.SqlServer.Dts.Runtime.Application(); --> I got an exception here.
        DTSExecResult pkgResult;

        PkgLocation = Properties.Settings.Default.PackageLoc + "\"Package1.dtsx";
        textstring("Loading Package...");
        m_worker2.ReportProgress(30);
        pkg = _app.LoadPackage(PkgLocation, null);
        textstring("Executing Package...");
        m_worker2.ReportProgress(30);
        pkgResult = pkg.Execute();
        textstring("Finished...");
        m_worker2.ReportProgress(30);
        textstring(pkgResult.ToString());
        m_worker2.ReportProgress(30);
    }

Can anyone point me out the right way. I don't know what is meant by that error. Please enlighten me?

3

3 Answers

3
votes

That means, that you mixed x86 and x64 architectures. If your application is x86 (=32 Bit) architecture, you can not use x64 (=64 Bit) compiled assemblies. Try to compile your application with Any CPU or x64.

From MSDN:

To set the Platform target property (C#)

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Click the Build tab.

  3. Choose a CPU type from the Platform target list. The options are Any CPU (the default), x86, x64, and Itanium.

Here is the complete Link: How to: Optimize an Application for a Specific CPU Type

Important: if you compile for x64 and use x64 assemblies, your application will not run under 32-Bit versions of Windows.

2
votes

I recently upgraded to SQL 2016 and my VB app stopped running my package. I saved the package no problem to SQL 2016. VB wouldn't run it via the LoadFromSqlServer method. Just reported Could not load file or assembly 'Microsoft.SqlServer.DTSRuntimeWrap' What fixed it for me was to delete the old 12.0 manageddts reference and adding the new 13.0 reference (see image) enter image description here

-1
votes

Depending on your version of SQL Server Data Tools that is installed on your system, you must add a specific version of Microsoft.SqlServer.DTSRuntimeWrap in your C# Application.

For example if you have SQL Server Data Tools 2010 installed you must add Microsoft.SqlServer.DTSRuntimeWrap 11.0.0.0, and for SQL Server Data Tools 2012 you must add Microsoft.SqlServer.DTSRuntimeWrap 12.0.0.0