XCAD.NET
XCAD.NET
Framework for .NET (C# and VB.NET) to create modern application for CAD systems (SOLIDWORKS, SOLIDWORKS Document Manager, Autodesk Inventor, etc.)
Get technical support Connect to xCAD community on Discord server Explore code and application examples xCAD.NET Templates for Visual Studio and VS Code Access source code

Troubleshoot SOLIDWORKS add-in developed with xCAD framework


xCAD framework outputs the trace messages which simplifies the troubleshooting process. The messages are output to the default trace listener. Message category is set to XCad.AddIn.[AddIn Name]

If add-in is debugged from Visual studio than the messages are output to Visual studio Output tab as shown below:

Trace messages in the output window of Visual Studio
Trace messages in the output window of Visual Studio

Otherwise messages can be traced via DebugView utility by Microsoft

  • Download the utility from the link above
  • Unzip the package and run Dbgview.exe
  • Set the settings as marked below:

Enable Capture Win32 and Capture Events options from the toolbar (marked in red)

Trace settings in the DebugView utility toolbar
Trace settings in the DebugView utility toolbar

Alternatively set the capture options via menu as shown below:

Trace settings in the DebugView utility menu
Trace settings in the DebugView utility menu

Set the filter to filter xCAD messages by clicking the filter button (marked in green)

Trace settings filter in the DebugView utility
Trace settings filter in the DebugView utility

Messages will be output to trace window

Trace messages in the debug view
Trace messages in the debug view

Use eraser button to clean messages (marked in blue)

Notes

  • Trace output is very powerful tool for troubleshooting the add-in on clients computers
  • DebugView tool is lightweight and doesn't require installation and is provided by Microsoft
  • Trace messages will be also output in the release mode
  • xCAD framework will output the exception details if thrown while loading of the add-in which can help solving the problem when add-in cannot be loaded

Custom messages and exceptions can be logged from xCAD module. Log can be accessed from IXExtension::Logger property allowing to log custom messages and exception from the module.

using System;
using System.Runtime.InteropServices;
using Xarial.XCad.Base;
using Xarial.XCad.SolidWorks;

namespace Xarial.XCad.Documentation
{
    [ComVisible(true), Guid("CD7222A3-A70E-421A-8998-46FC184AEDDC")]
    public class LogAddIn : SwAddInEx
    {
        internal const string LOGGER_NAME = "MyAddInLog";

        public override void OnConnect()
        {
            try
            {
                Logger.Log("Loading add-in...");

                //implement connection
            }
            catch (Exception ex)
            {
                Logger.Log(ex, true, Base.Enums.LoggerMessageSeverity_e.Fatal);
                throw;
            }
        }
    }
}

Debugging xCAD.NET Source Code

Starting from version 0.6.0 xCAD.NET supports Source Link allowing to step into original source code directly from the nuget package.

To enable Source Link for xCAD.NET

  • Set the options in Debugging section of Visual Studio options dialog as below
    • Unselect Enable Just My Code option
    • Select Enable Source Link support option

Debugging options in Visual Studio
Debugging options in Visual Studio

  • Select NuGet.org Symbol Server in the Symbols section

Visual Studio symbols
Visual Studio symbols

Now it is possible to press F11 or click step into command to debug the source code of xCAD.NET. The following warning will be displayed. Select the appropriate option

Warning for downloading source code
Warning for downloading source code

Note. It is recommended to disable Source Link when not used

See below the video demonstration of debugging the xCAD.NET source code using Source Link


Powered by Docify