Changes

PC Example Applications

1,841 bytes added, 17:26, 11 November 2020
Debugging Unmanaged Code in Visual Studio
* OnOffWPF.sln - Demonstrates Bit Commands to KFLOP with WPF GUI
 
 
==Debugging From .NET into Unmanaged C++ Code of KMotion Libraries==
When debugging Managed code such as an App written in C# .NET it is sometimes helpful to step into or set breakpoints or view variables in the Unmanaged C++ KMotion Libraries to understand exactly what is happening.  Visual Studio allows you to do this but the Project Properties for the App must have the "Enable native code debugging" option enabled.
 
 
[[File:EnableNativeCodeDebugging.png|none|link=]]
 
 
Then for example when debugging on a line of Managed Code that makes a call to the KMotion Libraries such as this:
 
 
[[File:StepInto.png|none|link=]]
 
 
Use the debugger Debug | Step Into Menu button or tool bar button.
 
 
Note in some cases Right-Click Step Into Specific can be used or may be necessary to specify exactly what to Step into as shown below:
 
 
[[File:StepIntoSpecific.png|none|link=]]
 
 
Stepping into functions should eventually get into the C++ Libraries as shown here:
 
 
[[File:IntoCppCode.png|none|link=]]
 
 
If Visual Studio skips over Unmanaged code calls and refuses to step into the Unmanaged functions you may have some odd Visual Studio debug options set.  Exit debugging and within Visual Studio use the Debug | Options | Debugging | General and select options as shown below:
 
 
 
[[File:UnmanagedDebugOptions.png|none|link=]]
 
 
 
Note one disadvantage of having native code debugging enabled is that Visual Studio's powerful Edit and Continue option to make changes on-the-fly is not available.  So when not necessary to debug into Unmanaged code it is may be desirable to disable native code debugging.
 
 
 
Note the App being debugged should be using the Debug Versions of the KMotion Libraries from the Debug folder rather than the Release folder.  The BuildAllLibs.sln in configuration Debug may be used to create the Debug Versions.
 
Bureaucrat, administrator
469
edits