【问题标题】:Mixed mode assembly error running in F# Interactive在 F# Interactive 中运行的混合模式程序集错误
【发布时间】:2015-06-20 22:16:02
【问题描述】:

我已尝试将以下 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 在 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()

【问题讨论】:

  • 在您的 .config 文件中查看程序集重定向,或者构建您所依赖的任何库,这些库是针对 2.0 从源代码构建的。
  • 尝试使用融合日志来确定正在加载的 FSharp.Core 版本,这将可靠地回答您的问题。版本控制 W.X.Y.Z 的意思是,F# 版本 X.Y.Z 运行在 .net 版本 W 上。所以如果你看到类似 4.x.y.z 的东西,它运行在 .net 4 上。

标签: powershell deployment ssis f# f#-interactive


【解决方案1】:

根据this question,您应该可以通过在%programfiles(x86)%\Microsoft SDKs\F#\3.0\Framework\v4.0\fsi.exe.config<configuration> 节点内添加以下内容来解决此问题

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

【讨论】:

  • 这似乎有效!如果我只保留此配置更改,您是否知道这是否会对通过 fsi 运行未来的脚本产生任何影响?我发现这个link 可能只在本地工作,而不是通过配置更改全局工作。
  • AFAIK 这不会引起问题,尽管可能存在一些边缘情况。运行时技巧看起来很有趣。
猜你喜欢
  • 2012-12-28
  • 1970-01-01
  • 2012-10-06
  • 1970-01-01
  • 2016-05-08
  • 2013-01-26
  • 2011-03-11
  • 2015-08-03
  • 1970-01-01
相关资源
最近更新 更多