2009-08-12 16 views

risposta

18

È possibile utilizzare Debugger.IsAttached per determinare se il programma è in fase di debug.

If Not Debugger.IsAttached Then 
    DoSomething() 
End If 

EDIT Se hai sempre voglia di ignorare il codice DoSomething nella build di debug, se un debugger è in uso, utilizzare conditional compilation con #If, qualcosa di simile

#IF DEBUG Then 
    DoSomething() 
#End If 
9

Cosa intendi con la modalità di debug? Se si fa riferimento a una build di debug, è possibile utilizzare #if DEBUG per verificare che:

#if DEBUG 
    // this is included in a debug build 
#else 
    // this is not included in a debug build 
#endif 
1

è possibile utilizzare la funzione IsDebuggerPresent

<DllImport("kernel32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _ 
Public Shared Function IsDebuggerPresent() As Boolean 
End Function 

if not isDebuggerPresent() then 
Do something() 
end if 
Problemi correlati