Generating a circuit using xsd.exe

I am trying to create a circuit for some type from an assembly using xsd.exe, here is the command line:

xsd.exe TestAssemby.dll /t:TestType

Here is my mistake:

Error: An error occurred while processing the "TestAssemby.dll". Unable to load one or more of the requested types. Get the LoaderExceptions property for more information.

I copied the dll link to the folder where this is located .

but still get the same error

I have some questions:

  • What are the possible causes of this error?
  • How should I use the LoaderExceptions property? (an example will be very useful)
+6
source share
5 answers

xsd.exe dll .

Windows XP xsd.exe, , , , .

- , (, , ) Visual Studio, xsd.exe , :

namespace XsdExeTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var rgs = new string[]
                          {
                              @"C:\publish\bin\SoAndSo.Library.dll",
                              "/type:SoAndSoNamespace.SoAndSoClassName"
                          };

            XsdTool.Xsd.Main(rgs);
        }
    }
}

., "write file schema0.xsd". , , , .

, , , .

+2

ardave. , WTF xsd.exe.

static void Main(string[] args)
{
    var rgs = new string[]
    {
        @"{path_to_dll}",
        "/type:{type_name}"
    };

    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();
}

, , XSD.exe AppDomain.CurrentDomain.FirstChanceException XsdTool.Xsd.

+2

DLL xsd.exe .

  • .
  • "cd c:\myproject\bin"
  • xsd.exe "xsd myproject.dll/t: MyClass"
+1

: . xsd.exe .., XSD.

, , , Visual Studio ( IDE ) , XSD. , xsd.exe. , , .

0

, , , , .

xsd.exe ( ), - , .

: .

xsd.exe, :

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\x64\xsd.exe

:

YourAssembly.dll /t:Your.Type

( → Windows → ) System.Reflection.ReflectionTypeLoadException. CLR, .

F5, .

The XSD console window should appear. Then Visual Studio should abort the process and display the Exception popup . Here you can check the type load exception.

You should also see an exception in the Locals window .

In fact, this should work for any build, you just need a solution and project to start a debugging session. It may even be an empty solution / project.

0
source

All Articles