4

I am trying to use the tool XSD.EXE to generate some class files from an XSD. Whether there is anything to be gained from the resulting files is another question, but I would like to see what is generated. I found this reference, which notes:

Which, thanks to Luke over on the F# Visual Studio team, means I can do this:

xsd.exe fpml-asset-4-z.xsd /classes /l:”Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider, FSharp.Compiler.CodeDom, Version=1.9.9.9, Culture=neutral, PublicKeyToken=a19089b1c74d0809″

Which is splendid. I don't have the same version of the code dom - so looking at the GAC I changed the line to:

xsd.exe RIXML-datatypes-2_3_1.xsd /classes /l:"Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider, FSharp.Compiler.CodeDom, Version=2.0.0,0, Culture=neutral, PublicKeyToken=a19089b1c74d0809"

Which yields:

C:\Users\Desktop\CSharpSamples\ResearchUploader\Fc-RixmlLib>xsd.exe RIXML-datatypes-2_3_1.xsd /classes /l:"Microsoft.FSharp.Compiler.CodeDom.FSharpCodePr ovider, FSharp.Compiler.CodeDom, Version=2.0.0,0, Culture=neutral, PublicKeyToken=a19089b1c74d0809" Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.0.30319.1] Copyright (C) Microsoft Corporation. All rights reserved. Error: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

If you would like more help, please type "xsd /?".

Thoughts?

4

3 回答 3

3

我遇到了同样的问题“HRESULT 异常:0x80131047” - 没有设法解决它,但有一个丑陋的解决方法:

  1. 创建一个新的 C# 控制台应用程序
  2. 请参阅这篇文章了解如何以编程方式执行与 xsd.exe 相同的操作
  3. 添加对 F# powerpack 的 CodeDom dll 的引用
  4. 使用 Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider 而不是 CSharpCodeProvider

花了一个小时试图让 xsd.exe 工作,我只花了 5 分钟就用这种方式暴力破解了它。

这可以很容易地制作成 xsdfs.exe 或其他东西,以省去人们制作 xsd.exe 使用 f# 代码 dom 的麻烦 :)

于 2013-01-04T23:20:18.280 回答
1

这在我看来是正确的。您能否再次检查该程序集是否已安装在 GAC 中?
这是您可以输入到“Visual Studio 命令提示符”的命令:

> gacutil -l | find "FSharp.Compiler.CodeDom"

我有:

FSharp.Compiler.CodeDom, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=a19089b1c74d0809, processorArchitecture=MSIL
于 2010-12-01T18:59:02.093 回答
0

离开这Microsoft部分,安装到 GAC 后,它应该可以工作。他们不久前改名了。

在安装(反汇编和组装 - ildasm,gacutil fun)之后,我可以同时使用xsd.exe编辑器内的 C# 方法(重写为 F#)。谢谢 :)

于 2015-06-18T23:17:24.123 回答