SqlDataConnection类型提供程序抛出SEHException

时间:2017-06-22 05:56:04

标签: .net f# type-providers

我正在使用FSharp.Data.TypeProviders-package中的SqlDataConnection类型提供程序来访问MSSQL数据库中的数据。我收到了以下SEHException

Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
   at System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.PopulateProperties(Filter filter, RuntimeType declaringType, Dictionary`2 csPropertyInfos, Boolean[] usedSlots, ListBuilder`1& list)
   at System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.PopulateProperties(Filter filter)
   at System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.GetListByName(Char* pName, Int32 cNameLen, Byte* pUtf8Name, Int32 cUtf8Name, MemberListType listType, CacheType cacheType)
   at System.RuntimeType.RuntimeTypeCache.MemberInfoCache`1.Populate(String name, MemberListType listType, CacheType cacheType)
   at System.RuntimeType.GetPropertyCandidates(String name, BindingFlags bindingAttr, Type[] types, Boolean allowPrefixLookup)
   at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
   at Microsoft.FSharp.Quotations.PatternsModule.bindProp[a](Type tc, String propName, FSharpFunc`2 retType, FSharpFunc`2 argTypes, FSharpList`1 tyargs)
   at Microsoft.FSharp.Quotations.PatternsModule.u_constSpec@1482-39.Invoke(FSharpList`1 tyargs)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1358-2.Invoke(BindingEnv env)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1358-2.Invoke(BindingEnv env)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1358-2.Invoke(BindingEnv env)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1358-2.Invoke(BindingEnv env)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1372-4.Invoke(BindingEnv env)
   at Microsoft.FSharp.Quotations.PatternsModule.u_Expr@1380-7.Invoke(BindingEnv env)
   at Microsoft.FSharp.Quotations.PatternsModule.deserialize(Type localAssembly, Type[] referencedTypeDefs, Type[] spliceTypes, FSharpExpr[] spliceExprs, Byte[] bytes)

我几乎每晚都在夜间跑步时遇到这种异常。当我在白天跑它时它永远不会出现。

之前是否有人遇到此问题,或者是否有人就如何找出导致此错误的原因提出任何建议?

我在F#4.0。我不知道这是类型提供程序中的错误,也不是F#中的错误。

编辑:不幸的是我无法发布失败的实际代码,但我创建了一段虚拟代码,它显示了所涉及的函数的外观。我希望这至少可以提供一些帮助(例如显示使用引用的地方)。

// Library 1
type schema = SqlDataConnection<ConnectionString = """...""", ForceUpdate = false, LocalSchemaFile = "schema.dbml">

// Library 2
module Data =
    let getData filter =
        let ctx = schema.GetDataContext()
        query {
            for row in ctx.Table do
            where ((%filter) row)
            select row) }
        |> Seq.groupBy (fun row -> row.Date)
        |> Seq.map (fun (_, rows) -> rows |> Seq.maxBy (fun row -> row.Column1))
        |> Seq.toArray

// Library 3
module Failing =
    let failingFunction () =
        let data = Data.getData <@ fun row -> // Fails on this line
            row.Column2 = "Foo" && row.Column3 = "Bar")
        ...

0 个答案:

没有答案