xsd to class (C#) in visual studio 2019



我正在学习教程,一步打开"VS2012 手臂交叉工具命令提示符"并执行

xsd file.xsd /classes

我在计算机上找不到"VS2012 手臂交叉工具命令提示符"(我猜这是因为我使用的是 VS2019(,所以我打开了"VS 2019 的开发人员命令提示符",但是当我运行该命令时,我收到一个错误:

"XSD"不被识别为内部或外部命令、程序或可执行文件

有人可以告诉我如何在VS 2019中从xsd文件创建类吗?谢谢你的时间。

一旦你安装了Windows SDK。以下内容可能对您有所帮助...它是.NET Core。浏览到 xsd.exe并在 VS 2019 中添加对它的引用。

class Program
{
    static void Main(string[] args)
    {
        var rgs = new string[]
        {
            @"PathToYourDLLMy.dll",
            "/type:ClassNameToGen"
        };
        AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
        {
            string error = e.Exception.ToString();
            var typeLoadException = e.Exception as ReflectionTypeLoadException;
            if (typeLoadException != null)
            {
                foreach (var exception in typeLoadException.LoaderExceptions)
                {
                    error += Environment.NewLine + Environment.NewLine + exception.ToString();
                }
            }
            Console.WriteLine(error);
        };
        XsdTool.Xsd.Main(rgs);
        Console.ReadLine();
    }
}

最新更新