简体   繁体   中英

xsd to class (C#) in visual studio 2019

I am following a tutorial, in one step it opens "VS2012 arm cross tools command prompt" and executes

xsd file.xsd /classes

I can't find "VS2012 arm cross tools command prompt" on my computer (my guess it's because I'm using VS2019) so I open the "Developer command prompt for VS 2019" instead, but when I run the command, I get an error:

"xsd" is not recognized as an internal or external command, program or executable batch file

Can someone tell me how I can create a class from an xsd file in VS 2019? Thank you for your time.

Once you have installed the Windows SDK . The following could be of help to you...it is .NET Core. Browse to the xsd.exe and add a reference to it in VS 2019.

class Program
{
    static void Main(string[] args)
    {
        var rgs = new string[]
        {
            @"PathToYourDLL\My.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();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM