c# - 如何使用 visual studio 命令提示符从 C# 类文件生成 xsd?

标签 c# visual-studio-2010 visual-studio xsd xsd.exe

我正在使用以下命令,但它不起作用:

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin>xsd /c /l:cs SubsystemReg.cs

假设这是我的类(class):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PaymentControllerGUI
{
    public class EmptyClass
    {
    }
}

我正在尝试这个。

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin>xsd/c/l:cs EmptyClass.cs

错误:

invalid command line argument: 'SubsystemReg.cs'

最佳答案

使用 XSD.exe,您应该传递编译您的类的 DLL 文件路径,改为 你现在传递的 CS 类代码文件本身。

例如,如果您的类在 SubsystemReg.dll 中编译,则像这样调用 XSD.exe:

XSD.exe C:\SubsystemReg.dll

这是来自 MSDN 的示例:

The following command generates XML schemas for all types in the assembly myAssembly.dll and saves them as schema0.xsd in the current directory.

xsd myAssembly.dll  

更新:

您可以通过指定类型的完全限定路径从特定类型的 DLL 生成 XSD,例如:

xsd.exe YourAssembly.dll /type:YourNamespace.YourType

根据您的情况,只需执行以下操作:

xsd.exe PaymentControllerGUI.dll /type:PaymentControllerGUI.EmptyClass

关于c# - 如何使用 visual studio 命令提示符从 C# 类文件生成 xsd?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22192313/

相关文章:

c# - 使用 .NET 5 Azure Functions 中的 Content-Type multipart/form-data 从 HttpRequestData 获取 POST 参数

html - 如何强制 Visual Studio 2010 刷新其错误列表窗口?

c# - 避免使用TreeView和HierarchicalDataTemplate破坏MVVM

visual-studio - 以编程方式找到VS2017安装目录

.net - 如何安装调试器可视化工具?

c# - 是否可以更改用户 SFTP 密码 (renci.sshnet)

c# - 有没有开源的SQL语句转LINQ的软件?

c# - 管道缓冲区保留直到处理完成

c++ - 多源 .cpp 文件问题

c# - 如何使用 GUI 在 Visual Studio 项目中添加和编译 Windows 窗体,而不是直接从 Visual Studio?