F# Interactive 中的混合模式程序集错误 运行

Mixed mode assembly error running in F# Interactive

我已尝试将以下 powershell script 用于将 2012 SSIS 项目部署到 F# 脚本。

当我尝试 运行 评估 catalog.Create() 行时通过 F# Interactive 执行此操作时,我似乎遇到了以下错误:

System.IO.FileLoadException:混合模式程序集是针对 运行 时代的 'v2.0.50727' 版本构建的,如果没有额外的配置信息,无法在 运行 时代的 4.0 中加载。 在 Microsoft.SqlServer.Management.IntegrationServices.Catalog.CheckDatabase(IntegrationServices 商店) 在 Microsoft.SqlServer.Management.IntegrationServices.Catalog.Create(布尔值 execSsisStartup) 在.$FSI_0007.main@() 由于错误停止

我正在 运行使用 Microsoft Visual Studio Express 2012 for Web 进行此操作。难道 F# interactive 是 运行ning 在 4.0 而不是 2.0 运行 的时候?这能以某种方式改变吗?

我转换的脚本开头如下:

// 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()

基于 this question,您应该可以通过在 %programfiles(x86)%\Microsoft SDKs\F#.0\Framework\v4.0\fsi.exe.config

<configuration> 节点内添加以下内容来解决此问题
<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
</startup>