0

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()
jeremyh
  • 612
  • 4
  • 14
  • 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 Apr 15 '15 at 06:48
  • 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 Apr 15 '15 at 08:19

1 Answers1

1

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>
Community
  • 1
  • 1
latkin
  • 16,402
  • 1
  • 47
  • 62
  • This seems to work! Do you know if this will have any impact on running future scripts through fsi if I just leave this config change in? I found this [link](https://code.msdn.microsoft.com/3DVisualization-Visual-79471042/sourcecode?fileId=18993&pathId=995930383) that might just work locally rather than globally through a config change. – jeremyh Apr 15 '15 at 21:26
  • AFAIK this won't cause problems, though there could be some edge cases. The runtime trick looks interesting. – latkin Apr 16 '15 at 01:04