XSD.EXE 用于从 XSD 生成 F# 类

发布于 2024-10-05 10:05:26 字数 1220 浏览 0 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雪化雨蝶 2024-10-12 10:05:26

我遇到了同样的问题“Exception from 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 的麻烦:)

I had the same problem "Exception from HRESULT: 0x80131047" - did not manage to solve it but there is an ugly workaround:

  1. Create a new C# console application
  2. See this post for how to programatically do the same thing as xsd.exe
  3. Add reference to your F# powerpack's CodeDom dll
  4. Use Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider instead of CSharpCodeProvider

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 :)

不喜欢何必死缠烂打 2024-10-12 10:05:26

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

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

我得到:

FSharp.Compiler.CodeDom, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=a19089b1c74d0809, processorArchitecture=MSIL

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":

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

I got:

FSharp.Compiler.CodeDom, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=a19089b1c74d0809, processorArchitecture=MSIL
情深如许 2024-10-12 10:05:26

去掉 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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文