Error When Running SSIS package

I'm trying to run an SSIS package from VB.NET. I can get/change the values of variables from the package I intend to run, however I cannot run it.

Below is a snippit of code (text in square brackets [] is shortened (eg. description of a file path) and not literal code)

Private Sub ExecuteSSIS()

    'Set Location of SSIS package
    Dim SSISPackagePath As String = [path to package]

    'Set Location of SSIS config file
    Dim SSISConfigPath As String = [path to config file]

    'Create instances of DTS classes
    Dim sMessage As String = ""
    Dim pkg As New Package
    Dim app As New Microsoft.SqlServer.Dts.Runtime.Application
    Dim pkgResults As DTSExecResult

    'Load SSIS package
    pkg = app.LoadPackage(SSISPackagePath, Nothing)

    'Setup SSIS Config
    pkg.EnableConfigurations = True
    pkg.ImportConfigurationFile(SSISConfigPath)

    'Set SSIS global variables
    pkg.Variables("User::Database1").Value = db1
    pkg.Variables("User::Database2").Value = db2
    pkg.Variables("User::TableName").Value = tbname

    'DEBUG: Proof that DTS/SSIs variables are being manipulated
    MsgBox("Variables After Change" & vbNewLine & _
            "db1: " & pkg.Variables("User::Database1").Value.ToString() & vbNewLine & _
            "db2: " & pkg.Variables("User::Database2").Value.ToString() & vbNewLine & _
            "Tab: " & pkg.Variables("User::TableName").Value.ToString() & vbNewLine)

    'Execute SSIS
    pkgResults = pkg.Execute()


    'Error Check 1
    If pkgResults = DTSExecResult.Success Then
        MsgBox("DTSExecResult: Package ran successfully")
    ElseIf pkgResults = DTSExecResult.Completion Then
        MsgBox("DTSExecResult: Package Completed")
    ElseIf pkgResults = DTSExecResult.Failure Then
        MsgBox("DTSExecResult: Package ran successfully")
    ElseIf pkgResults = DTSExecResult.Canceled Then
        MsgBox("DTSExecResult: Package Cancelled")
    Else
        MsgBox("DTSExecResult: Package Unknown Error")
    End If


    'Error Check 2
    Dim warning As DtsWarning
    If pkgResults > DTSExecResult.Success Then
        For Each warning In pkg.Warnings
            sMessage = "Step " & warning.SubComponent & " Failed - " & _
                " - Error: " & warning.WarningCode & _
                " - Source: " & warning.Source & _
                " - Description: " & warning.Description
        Next
    End If
    If Len(sMessage) > 0 Then
        MsgBox("SSIS error: " & vbNewLine & sMessage)
    End If

End Sub

Error check 1 is returning Package successful. Error Check 2 is returning the error:

Error: -2147381246

Source: -[Title of first step in SSIS package]

Description:- DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed(1)...

Edit: (Extra Info) SSIS package runs sucessfully when called directly from the DTSX file or source, but failes when called from the .NET application

Answers


I found the answer to this from this article:

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/03bae0fc-b51c-4258-a80a-8426e855576b/mixed-mode-assembly-and-uselegacyv2runtimeactivationpolicy?forum=sqlintegrationservices

The problem is that one of the libraries in Visual Studio 2010 (ManagedDTS.dll) is faulty, and so compatability options need to be added the the project's 'App.config' in order to make certain features work.

< startup startup="" useLegacyV2RuntimeActivationPolicy="true" >

<?xml version="1.0"?>
<configuration>
   <startup startup="" useLegacyV2RuntimeActivationPolicy="true">
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>

Need Your Help

ASP.Net Linq to Entities: An attempt to attach an auto-named database failed

c# asp.net linq-to-entities connection-string

The problem is that the path to my database shown in the error below is incorrect. I cannot find where that path is set as it is not in the settings or in any of the project files. What am I miss...

How can I create a local user profile for the anonymous user of an ASP.Net MVC application under IIS 7?

asp.net-mvc iis-7 windows-7 forms-authentication sql-server-express

I've been experimenting with ASP.Net MVC, and have come across a problem that is probably not specifically MVC related. But I cannot get the authentication in the default MVC application (the one c...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.