0
votes

I have tried to convert the following powershell script for deploying a 2012 SSIS Project to an F# script.

I seem to be getting the following error when I try and run this through F# Interactive when evaluating the catalog.Create() line:

System.IO.FileLoadException: 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. at Microsoft.SqlServer.Management.IntegrationServices.Catalog.CheckDatabase(IntegrationServices store) at Microsoft.SqlServer.Management.IntegrationServices.Catalog.Create(Boolean execSsisStartup) at .$FSI_0007.main@() Stopped due to error

I am running this using Microsoft Visual Studio Express 2012 for Web. Could it be that F# interactive is running under 4.0 instead of the 2.0 runtime? Can this be changed somehow?

The start of the script I converted can be seen below:

// Variables
module Global =

    let projectFilePath = @"C:\Projects2012\Internal Reporting\SourceControl\RKN BI DataWarehouse Solution\Releases\Release 1.1.1\SSIS\SSIS Dynamics CRM Staging Load.ispac"
    let projectName = "SSIS Dynamics CRM Staging Load"
    let folderName = "RKNBI"
    let environmentName = "Dev"

// Load the IntegrationServices Assembly
#r "Microsoft.SqlServer.Management.Sdk.Sfc"
#r "Microsoft.SqlServer.Management.IntegrationServices"
#r "Microsoft.SqlServer.Smo"
#r "Microsoft.SqlServer.ConnectionInfo"

open System.Data
open Microsoft.SqlServer.Management.Sdk.Sfc
open Microsoft.SqlServer.Management.IntegrationServices
open System.IO

printfn "Connecting to server ..."

// Create a connection to the server
let sqlConnectionString = "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;"
let sqlConnection = new SqlClient.SqlConnection(sqlConnectionString)

// Create the Integration Services object
let integrationServices = IntegrationServices(sqlConnection)

printfn "Removing previous catalog ..."

// Drop the existing catalog if it exists
if (integrationServices.Catalogs.Count > 0) then
    integrationServices.Catalogs.["SSISDB"].Drop()
else
    ()

printfn "Creating new SSISDB Catalog ..."

// Provision a new SSIS Catalog
let catalog = Catalog(integrationServices, "SSISDB", "SUPER#secret1")
catalog.Create()
1
Look into assembly redirects in your .config file, or build whichever libraries you're depending on that are built against 2.0 from source. - ildjarn
try using the fusion log to figure out which version of FSharp.Core is being loaded, that will answer your question reliably. The versioning W.X.Y.Z means, F# version X.Y.Z running against .net version W. So if you see something like 4.x.y.z, it runs against .net 4. - Daniel Fabian

1 Answers

1
votes

Based on this question, you should be able to work around this by adding below inside the <configuration> node of %programfiles(x86)%\Microsoft SDKs\F#\3.0\Framework\v4.0\fsi.exe.config

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
</startup>