Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify debugging in VisualStudio

I have an interesting problem.

Is it possible to identify if an assembly is running in Visual Studio?

Look at the following code.

if(FoundThatYouAreDebuggingInVisualStudio)
{
    Print "Hello"
} 
else 
{
    Print "Hi"
}

The above code is present in a .NET assembly (say XYZ) which is built in Release mode. The user is debugging his/her application (say ABC) that references to XYZ assembly.

I need to identify if the user is debugging in the Visual Studio or he is just running the ABC application.

Any ideas?

-D

like image 401
dattebayo Avatar asked Apr 03 '26 00:04

dattebayo


1 Answers

Perhaps you're looking for System.Diagnostics.Debugger.IsAttached

like image 113
Ken Browning Avatar answered Apr 04 '26 14:04

Ken Browning



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!