c# - Disable "Attach to debugger" Debugger.Launch -


i got problem, have accidentally left "debugger.launch();" code in project, needed debugging application windows service.

now, i'am done projects, it´s working intended (mostly) but, every time start service, asks if want attach debugger.

the service has been packed msi-package, , more or less ready delivery. , guy handles packaging , such not @ office , none else know how or has authority it.

enough backstory..

  • can in way disable debugger code without repackaging service? - or have repackage?
  • is there startup command or prevent ask debugger?

i have been searching alot this, of existing questions/posts regards "prebuild" solutions, i'am looking "postbuild" solution.

[edit]

solution (some kind of..)

i have still no idea if possible prevent attaching, research i've done, seems impossible. therefore had recompile service.

as many of commented suggested implemented key in app.config, , simple "if-case" around "debugger.launch()", work perfectly. can choose attach debugger or not.

tamir vereds solution worked on local machine, , did not try on customers server, because of reason stated base code on kind of tweaks.

i accept answer, partly fix initial problem.

thank answering.

usually recommend recompiling application , allowing invoked argument or configuration cancelling debugger.launch call, since don't want recompile...

as documentation of debugger.launch() method:

if debugger attached, nothing happens.

you can take advantage of fact making small process "debug" original process.

since process windows service might need use auto-debugger-attach:

  • open registry editor typing regedit in cmd.
  • navigate to: hkey_local_machine\software\microsoft\windows nt\currentversion\image file execution options.
  • add key debugged application's .exe's name.
  • add string value key name debugger when value new "debugger process" path.

with fake debugger attached, original process return frm debugger.launch method without invoking debugger.

also might want fake debugger deattach somehow later on can still debug application when needed.

note sort of tweak , don't want base production code on kind of stuff.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -