Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

For the first time I am trying to execute a SSIS package from VB.Net (VS2013). My SQL Server is 2014. Looking at the sample code, it looks straight forward but I keep getting errors.

The error I get is
e Execute method on the task returned error code 0x80131621 (Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.). The Execute method must succeed, and indicate the result using an "out" parameter. "

It has me puzzled.

What I have tried:

My code is as follows....

Private Sub cmdRun_Click(sender As Object, e As EventArgs) Handles cmdTest2.Click

Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult
Dim local_DtsError As Microsoft.SqlServer.Dts.Runtime.DtsError = Nothing

Dim sLocationAndDtsx As String = "C:\SSIS_Testing\Package.dtsx"

pkgLocation = sLocationAndDtsx

pkg = app.LoadPackage(pkgLocation, Nothing)
pkgResults = pkg.Execute()

Dim sError As String = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

'MsgBox(pkgResults.ToString())

Dim results As Microsoft.SqlServer.Dts.Runtime.DTSExecResult = pkg.Execute()
'//Check the results for Failure and Success
If results = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure Then
Dim sErr As String = ""

For Each local_DtsError In pkg.Errors
Dim aa As String = local_DtsError.Description.ToString()
sErr = sErr + aa

MsgBox(sErr)

Next
End If

End Sub
Posted
Updated 12-Sep-17 11:12am

1 solution

You need to change your application's configuration:

useLegacyV2RuntimeActivationPolicy Attribute:

true
Enable .NET Framework 2.0 runtime activation policy for the chosen runtime, which is to bind legacy runtime activation techniques (such as the CorBindToRuntimeEx function) to the runtime chosen from the configuration file instead of capping them at CLR version 2.0. Thus, if CLR version 4 or later is chosen from the configuration file, mixed-mode assemblies created with earlier versions of the .NET Framework are loaded with the chosen CLR version. Setting this value prevents CLR version 1.1 or CLR version 2.0 from loading into the same process, effectively disabling the in-process side-by-side feature.
false
Use the default activation policy for the .NET Framework 4 and later, which is to allow legacy runtime activation techniques to load CLR version 1.1 or 2.0 into the process. Setting this value prevents mixed-mode assemblies from loading into the .NET Framework 4 or later unless they were built with the .NET Framework 4 or later. This value is the default.


Modify your app.config file to set useLegacyV2RuntimeActivationPolicy to true:
XML
<startup useLegacyV2RuntimeActivationPolicy="true">
    ...
</startup>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900