How do I prevent deployed .NET Assembly from throwing Microsoft C++ exception: "xsd_binde​r::Malform​edDocument​Error" in C# VS driver project?

When native code debugging is enabled (via Project > [Application Name] Properties > Debug in Visual Studio), my C# driver application, which initializes a deployed .NET Assembly from MATLAB, throws repeated exceptions and does not proceed. The error message is as follows:
Exception thrown at 0x000007FEFCEAA06D in AxonLite.exe: Microsoft C++ exception: xsd_binder::MalformedDocumentError at memory location 0x00000000003425E0.
How can I prevent the deployed .NET Assembly from throwing the Microsoft C++ exception "xsd_binder::MalformedDocumentError" in my C# Visual Studio driver project when native code debugging is enabled?

 Accepted Answer

When "Enable native code debugging" is selected in your project settings, you may encounter the "xsd_binder::MalformedDocumentError" C++ exception while initializing a deployed .NET Assembly from MATLAB in your C# Visual Studio driver project. This issue is related to a compatibility problem with the Visual Studio debugging engine.
To resolve this:
  1. In Visual Studio, go to Tools > Options.
  2. Navigate to Debugging > General.
  3. Check the box for "Use Managed Compatibility Mode".
With this setting enabled, your driver program should execute and debug as expected, without encountering the infinite exceptions.
This workaround replaces the default debugging engine with a legacy version, which can resolve compatibility issues, particularly when working with mixed-mode (managed and native) debugging scenarios. According to Microsoft documentation's on Specifying Debugger Options, "Managed Compatibility Mode" is useful if:
  • You are using a .NET Framework language other than C#, VB, or F# that provides its own Expression Evaluator (such as C++/CLI).
  • You want to enable Edit and Continue for C++ projects while mixed mode debugging.
Note that choosing Managed Compatibility mode disables some features that are implemented only in the default debugging engine.

More Answers (0)

Categories

Products

Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!