I am making a plug-in for Bricscad which is basically a dll that is used by the application. This plug-in uses both console commands and WPF windows. When I try to debug it and set breakpoints there is strange behaviour - if the code was called by the command it stops at the breakpoint and it is possible to debug it. However if I open one of my WPF windows and code in question is triggered from it(i.e. by pressing a button) it still breaks at the breakpoint however all I get is this message: "Your app has entered a break state, but no code is currently executing that is supported by the selected debug engine (e.g. only native runtime code is executing)." This happens in the scope of a single dll. dll was built with 4.5.1 .NET framework.
I have checked the modules from studio - dll is loaded as well as symbols for it. I have also tried to uncheck Just My Code option but to no effect. I have checked the threads - in both cases the code was executing in main thread. The only difference that I see is that this message only appears if code is called from WPF window.
Here is an example of xaml file that is used.
<Window x:Class="Plugin.Window"
Title="Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
MaxHeight="400"
MinHeight="350"
Width="400"
MinWidth="400" Height="350">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/Resource;component/AppDictonary.xaml">
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<StackPanel Orientation="Vertical" Margin="5">
<Button x:Name="_startButton" Content="Start" Width="100" Click="ButtonStart_Click" />
</StackPanel></Window>
And the function called by WPF
private void ButtonStart_Click(object sender, RoutedEventArgs e)
{
Foo();
}
If a breakpoint in Foo is triggered by a console command in Bricscad the debug is fine. But if its called from ButtonStart_Click the message manifests.
What could be the possible cause of this message? Have anyone encountered this behaviour(maybe in some other dlls)?
Maybe it is too late for you :D , but not for future readers.
Description:
Problem that you encountered is that source was not available on breakpoint in method which is invoked by some event (i used WindowsForms, but assume same sh*t is with WPF).
But, it happens only when displaying Form/Window as modal - if you display it as modeless, then it works! (Form.Show() - modeless, Form.ShowDialog() - modal)
Solution
From this link -> https://forum.bricsys.com/discussion/comment/25822/#Comment_25822
Edit:
Important I spent several hours debugging StackOverflowException followed by process crash and close, while running tests from NUnit Console (it was nasty, i had to debug with WinDbg and to inspect dump files).
Turned out changing this configuration made all those problems. So, keep it "false" only while you really want to debug code inside Windows Forms, otherwise switch to "true".
Here is code which i use for switching this config on and off (in Visual Studio/Tools you can add new commands (enable/disable) with "External tools..." with selecting new .exe with arguments)