简体   繁体   English

具有生成类型的项目在Assembly.GetExportedTypes()上失败

[英]Project with generated types fails on Assembly.GetExportedTypes()

I'm working on upgrading FSharp.Data.SqlClient to the latest version of the Type Provider SDK and I'm seeing an error when using generated types. 工作在升级FSharp.Data.SqlClient的类型提供SDK的最新版本,我使用生成的类型时收到错误。 The test project, which references numerous generated types, compiles just fine, but when I attempt to run the xunit tests I get the following exception: 引用众多生成类型的测试项目可以很好地进行编译,但是当我尝试运行xunit测试时,出现以下异常:

System.TypeLoadException: Could not load type 'BTL' from assembly 'SqlClient.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent does not exist. at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) at System.Reflection.RuntimeAssembly.GetExportedTypes() at <StartupCode$FSI_0005>.$FSI_0005.main@()

I'm not sure what the type BTL refers to - I don't see any symbol with that name anywhere in the test or in the type provider source. 我不确定BTL是指什么类型-在测试或类型提供程序源中的任何地方都看不到任何具有该名称的符号。 And I've confirmed that the issue is related to generated types - if I comment out all references to SqlEnumProvider but leave references to erased types, the tests all pass. 而且我已经确认该问题与生成的类型有关-如果我注释掉对SqlEnumProvider的所有引用,但保留对已擦除类型的引用,则测试全部通过。

Found an issue with the units-of-measure generated types - the base type of those provided types was None which was causing the error when reflecting over the assemblies types. 发现度量单位生成的类型存在问题-这些提供的类型的基本类型为“ None ,这在反映程序集类型时导致错误。 Changing the base type to Some typedefof<obj> did the trick and now all the tests are passing. 将基本类型更改为Some typedefof<obj>了目的,现在所有测试都通过了。

Incidentally, the mysterious BTL type came from data in the test database, which seems obvious in retrospect. 顺便说一句,神秘的BTL类型来自测试数据库中的数据,回想起来似乎很明显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM