XSD.EXE 用于从 XSD 生成 F# 类
我正在尝试使用 XSD.EXE 工具从 XSD 生成一些类文件。是否能从生成的文件中获得任何东西是另一个问题,但我想看看生成了什么。我找到了这个参考,其中指出:
这要感谢 F# 上的 Luke Visual Studio 团队,意味着我能做到 这个:
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″
这太棒了。我没有相同版本的代码 dom - 因此查看 GAC,我将这一行更改为:
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"
产生:
C:\Users\Desktop\CSharpSamples\ResearchUploader\Fc-RixmlLib>xsd.exe RIXML-datatypes-2_3_1.xsd /类 /l:"Microsoft.FSharp.Compiler.CodeDom.FSharpCodePr ovider,FSharp.Compiler.CodeDom, 版本=2.0.0,0,文化=中立, 公钥令牌=a19089b1c74d0809” Microsoft (R) Xml 架构/数据类型 支持实用程序 [Microsoft (R) .NET 框架,版本4.0.30319.1] 版权所有 (C) 微软公司。 版权所有。错误:给定的 程序集名称或代码库无效。 (HRESULT 异常:0x80131047)
如果您需要更多帮助,请 输入“xsd /?”。
想法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题“Exception from HRESULT: 0x80131047” - 未能解决它,但有一个丑陋的解决方法:
花了一个小时试图让 xsd.exe 工作,而我只花了 5 分钟就以这种方式暴力破解它。
这可以很容易地制作成 xsdfs.exe 或可以让人们省去让 xsd.exe 使用 f# 代码 dom 的麻烦:)
I had the same problem "Exception from HRESULT: 0x80131047" - did not manage to solve it but there is an ugly workaround:
Spent an hour trying to get xsd.exe to work, and it took me only 5 mins to bruteforce it this way..
This could be easily made into xsdfs.exe or something to save people the trouble of making xsd.exe to use the f# code dom :)
这对我来说看起来是正确的。您能否仔细检查该程序集是否已安装在 GAC 中?
您可以在“Visual Studio 命令提示符”中输入以下命令:
我得到:
That looks correct to me. Can you double check that the assembly is installed in GAC?
Here is a command that you can enter to "Visual Studio Command Prompt":
I got:
去掉
Microsoft
部分,安装到 GAC 后,它应该可以工作。他们不久前改了名字。我可以在安装(反汇编和汇编 - ildasm、gacutil fun)后使用 xsd.exe 和编辑器内 C# 方法(重写为 F#)。谢谢 :)
Leave off the
Microsoft
part, and after you installed to GAC, it should work. They changed names a while back.I can, after installing (disassemble and assemble - ildasm, gacutil fun) use both
xsd.exe
and the in-editor C# method (rewriting to F#). Thanks :)