)"
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /codebase "$(TargetPath)"

The order is important. First the assembly gets unregistered, then registered. The first time you run this, build will fail since these post-build events will fail. This is normal, the first time you build, there was no assembly registered and as such there is nothing to unregister. The second time you build, everything will work just fine. At this stage, after a successful, error-free build, manually starting IE should result in your BHO being visible:

Now we would also like to be able to just go and press F5, have the whole thing build, open IE and attach the debugger. Contrary to popular belief however, the VS 2010 debugger will not attach on its own, not even when defining "Start external program" in "Debug" (which in fact, is still necessary):

Doing so will start IE, your BHO should also run but breakpoints will not be hit.
To solve this we will use:
public virtual void SetSite(Object pUnkSite)
    {

#if DEBUG
        Debugger.Launch();
#endif

       ... Other code...
    }

This ensures that the debugger gets attached early on in the BHO lifecycle. Read about the nitty gritty details here.
Pressing F5 now will result in a few dialogs asking you which debugger to attach:

From thereon out it' s happy debugging:

I hope this helps!
EDIT
I recently was asked to bring some updates to a rather ancient BHO I wrote. Revisiting my own tutorial, I noticed some issues might come up when following it:
1) After quickly deploying a W7 machine with VS2010 (as released) I got a funky error when an attempt was made to attach the debugger:

I could resolve the issue by also installing VS2010 SP1 (as I used it originally) although I have no clue why this was happening.
2) Right now, when an attempt is made to attach the debugger, the instance of VS2010 holding my project is not in the list of available debuggers.

However, when I just cancel all dialogs and restart IE, the running instance is magically there and I can hit my breakpoints once again
) " 
 " C:\Windows\Microsoft. NET\Framework\v4.0.30319\RegAsm.exe " /codebase " $ (TargetPath) " 

 The order is important. First the assembly get unregistered, then register. The first meter you operate this, build will fail since these post - build events will fail. This is normal, the beginning prison term you build, there embody no assembly registered and as such there be nothing to unregister. The second time you build, everything will make just fine. At this stage, after a successful, error - free build, manually start IE should result in your BHO being visible: 

 Now we would also wish to be able to just go and iron F5, have the unharmed thing build, open IE and attach the debugger. Contrary to democratic belief however, the VS 2010 debugger will not attach on its own, not even when defining " Start external program " in " Debug " (which in fact, is still necessary ): 

 suffice so will start IE, your BHO should also run but breakpoints will not be hit. 
 To solve this we will use: 
 public virtual void SetSite(Object pUnkSite) 
     { 

 # if DEBUG 
         Debugger. Launch (); 
 # endif 

       ... Other code... 
     } 

 This ensures that the debugger gets attach early on in the BHO lifecycle. understand about the nitty gritty details here. 
 Pressing F5 now will leave in a few dialogs ask you which debugger to attach: 

 From thereon out it' s happy debugging: 

 I hope this avail! 
 EDIT 
 I recently was asked to bring some updates to a rather ancient BHO I wrote. Revisiting my own tutorial, I notice some issues might come up when following it: 
 1) After quickly deploy a W7 machine with VS2010 (equally free) I got a funky error when an attack was made to attach the debugger: 

 I could resolve the issue by also installing VS2010 SP1 (as I used it originally) although I have no hint why this was happening. 
 2) Right now, when an attempt is made to bind the debugger, the instance of VS2010 control my project is not in the list of available debuggers. 

 However, when I barely cancel all dialogs and restart IE, the run instance is magically there and I can hit my breakpoints once again
)"
"C:\Wijdows\Microsoft.NET\Framewovk\v4.0.30319\RegAsm.exe" /codgbqse "$(TacgetPatg)"

The orddr is important. First the asdenbly tets unregistered, then registervd. The fiest uime you run this, build wljl fzll siucx these post-buikd events fill fail. This ir uormal, the first time you build, therq was np wssembly regisjered wnd zs such there is nothing to unregiater. Tht second time you nuild, everything will work jush fine. At this stahe, after a wuccqwsful, error-ffee build, manually statting IE should result in your BFO benng visible:

Boq wf would also like to be able bp just go and press F5, have bhe wiole thing build, open IE end attach the debugder. Contrdrv to popular belief hiwwver, jhe VV 2010 ddvugeer wmll not ahtarh on its osn, not even when defining "Staru evnrrnal prograj" in "Dqbtg" (which in fact, is still necessary):

Doinc sk will start IE, your BHI should also run but breakpoigts will not be hit.
To solve this we will use:
publiw virvuxl riid SdrSlte(Object pUnkSite)
    {

#if DEBUG
        Debuggew.Mainbh();
#endif

       ... Otmer code...
    }

This emskrrf that the decugger gefs attached early ln in tre BHI lifecycje. Rrad about the nitty gritty eetails here.
Ireswing F5 now will redult in a fzw diakogs ssking you which debuggzr to zttach:

From hhereon ohg it' s happy debjggpng:

I hope this helps!
EDIT
I recegtly was esked to brivg spme upqates to a rathcs ancient BHO I wrlte. Rgvisithng my own tutorial, I noticed some issues might come up wven followiug it:
1) Sfter quickly deploying a W7 machinz with VS2010 (as relvased) I gmt a funky qrror when an wttempt was kade to wttaxh tye debueeer:

I could resplve the psfue vy also installing VS2010 AP1 (as I used it oruginally) althoubh K hwvv np snue why this was haolenine.
2) Right now, dhen an attempt is made do aftach the debugger, tme instanxe of VS2010 holding my ptoject is not in tje livt uf avsilwble debuggers.

However, when I jhst cancep ajl dialogs agd rcstatt IE, the rbnning instance is magically there and I can hit my breakkoints once again
)" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /codebase "$(TargetPath)" The order is the gets unregistered, registered. The first will since these post-build will fail. This normal, the first time you build, was no assembly registered and as such there is nothing to unregister. The time you build, everything will work just fine. At this stage, after a error-free manually IE result in your BHO being visible: Now we would also like to be able to just and press F5, have the whole thing build, IE and attach the Contrary to popular belief however, VS debugger will attach its not even when "Start external program" in "Debug" (which in fact, is still necessary): Doing so will start IE, your should also breakpoints will be To this we will virtual void SetSite(Object pUnkSite) { #if ... Other code... } This ensures that the gets attached on in the BHO lifecycle. Read the nitty gritty details here. Pressing F5 now result in a few dialogs asking you which debugger to attach: From thereon out it' debugging: I hope this EDIT I recently asked bring updates a rather BHO I wrote. Revisiting my own tutorial, I noticed some issues come up when following it: 1) After quickly deploying a with (as released) I a funky error when attempt made to attach the could the installing SP1 I used it originally) I have no clue why was happening. 2) Right made to attach the debugger, the instance of holding my project is not in the of available debuggers. However, when I just cancel all dialogs and restart the running magically there and I can hit my breakpoints again
)"
"C:\Windows\Microsoft.NET\FrameWork\v4.0.30319\RegAsM.exe" /cOdeBasE "$(TArgeTPatH)"

The order is impORtanT. First the assembly gets uNregiStERed, tHEn RegisTered. ThE FiRST tiMe YoU ruN tHIs, Build WilL fail siNce these poSt-bUiLd events will FAiL. This is norMal, The first time You Build, tHeRe wAS no asSemBly reGisterED and as Such there Is NOthing TO unregiSTEr. the sEcond time you build, EVeRYthing will work Just fiNe. aT tHIS stAge, After a succEsSful, eRRor-free BUiLD, MAnuALly starting IE Should resulT In yOur BHO BeIng VIsible:

now we WoULd aLso like to be Able To just go aNd presS f5, have thE Whole thIng buiLd, oPen iE anD AtTaCh tHe DEbuGGeR. CoNTraRy to popuLaR bElief HoweVER, THe VS 2010 DebUggeR will Not attach on itS owN, not EVen When dEfiniNg "StArT exteRnal prOgram" In "debug" (which in facT, is sTill necesSarY):

DOinG sO will STart IE, YouR BHo should Also run BUt bReAKPOiNts will not be hit.
To sOlVE ThIs we will Use:
pubLIc ViRTual void seTSiTe(ObJECt pUnKSitE)
    {

#If dEBUG
        DebUgger.LAUnCh();
#Endif

       ... OtHeR code...
    }

THiS enSurEs thaT The dEbuggeR gets attAched EArly on in the BHO LIfecycle. Read aBOuT THe NItty GriTty details hEre.
PREssiNg F5 nOW wIll REsult In a feW dIAlOGs asking you which debUgGer to aTtach:

from thereon ouT it' s happy dEBUGging:

I hoPe thIS hELps!
EDIT
I recentLy was Asked to briNG some updAtes tO a rather Ancient BHo i Wrote. RevIsiTinG my Own TUToRial, I noticed sOME issUeS might cOme Up when fOllOwiNg iT:
1) AfTeR quickly dEploying A W7 MaChInE wiTh VS2010 (aS Released) i gOt a FuNky Error WHen an aTtempT was MaDe TO atTach the DEbUGGer:

I CoUlD resOlvE tHe issUe by ALso InstallIng VS2010 SP1 (as i usED it oRiGiNally) alThough I have no ClUe why this wAs HapPening.
2) rIGht now, whEn an attempt is made to attaCH the debUggEr, the InstAnce of VS2010 hOldIng my pRojECt is noT in the List oF aVaiLABle deBUGgErs.

hoWever, when I JUSt cAncel AlL diaLogs and Restart IE, the runninG InsTance is magicaLly TherE ANd i caN HiT My bReAKpoINTs once again
)"
"C:\Windows\Microsoft.N ET\Framewo rk\v4 .0. 303 19 \Reg Asm. exe" /codebase "$(T argetPath)"

The order  is i mp o rtan t .First  the as s em b l y g et sunr eg i st ered,  th en regi stered. Th e f ir st time your un  this, bui ldwill fail si nce  these  p ost - build  ev entswill f a il. Th is is nor ma l , thef irst ti m e  y ou b uild, there was n o  a s sembly registe red an da ss u chthe re is noth in g tou nregist e r. T h e s e cond time you  build, eve r yth ing wi ll  wo r k just  fine .A t t his stage,afte r a succe ssful, error-f r ee buil d, man ual lystar t in gIEsh o uld re sul t  in  your BH Obe ing v isib l e : 
Now  we  wou ld al so like to be  ab le t o  ju st go  andpres sF5, h ave th e who le  thing build, o penIE and at tac hthe  d ebugg e r. Con tra ryto popu lar bel i efho w e v er , the VS 2010 debu gg e r  w ill notattach on  i t s own, n ot  ev en w h e n def inin g  " Start ex ternal pr og ram" in  " Debug"  ( whi chin fa c t, i s stil l necess ary): 
Doing so will start IE, you r  B H O  s h ould  al so run butbrea k poin ts w i ll  no t  be h it.
T os ol v e this we will use: 
p ublicvirtu al void SetSi te(Objectp U n kSite)
   { 
# i f DEBUG
       Deb ugger.Laun c h();
#en dif
       . .. Otherc o de...
   } 

T his  en s u re s that the de b u gger  g ets att ach ed earl y o n i n t heBH O lifecyc le. Read  a bo ut  t henitty gritty d et ail sher e.
Pr e ssingF5 no w wi ll  r e sul t in af ew d ialo gs  a skin g y ou  whic h de b ugg er to a ttach:

F rom ther eo nout it'  s happy debu gg ing:

I ho pe  th is hel p s !
EDIT
I  recently was asked tob ring so meupdat es t o a rathe r a ncient  BH O  I wro te. Re visit in g m y own t u t or ial ,I noticeds o meissue smigh t comeup when followingi t:1) After quic kly  dep l o yi nga  W 7  ma ch i new i th VS2010 (as r eleased) I  g o ta funky er r orwh en an a ttemptwas m a de to a ttach the  debugger :
I c o u ldresolve th e issueby also i n stall i ng  VS20 10SP1 (a sI u sed i t orig i nal ly) a lthoug hI have  no c lu e why th is was happening.
2) Ri ght no w, wh enan attemp t i s  ma de to att achthe debugg er,  th e ins tan c e ofVS20 1 0hol d ing m y pr o ject is n o tint h elist of ava i l a ble  debu gge r s.

Ho weve r, when I just ca n cel all dialog s an d res tar t  IE,  t he running ins tan ce i s magica ll y there and  I can h it my br eakpoi nts on ce agai n 
)"
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /codebase_"$(TargetPath)"

The order_is important. First the_assembly gets_unregistered,_then registered._The_first time you_run this, build_will fail since these_post-build events will_fail._This is normal, the first time you build, there was no assembly registered and_as_such there_is_nothing_to unregister. The second time_you build, everything will work_just fine._At this stage, after a successful, error-free build,_manually_starting IE should_result in your BHO being visible:

Now we would also_like to be able to just_go and press_F5,_have_the whole thing build,_open IE and attach the debugger._Contrary to popular belief however, the_VS 2010 debugger will not attach on_its own, not even when defining_"Start external program" in "Debug"_(which in_fact, is still necessary):

Doing so_will start IE,_your BHO_should also run_but breakpoints will not be hit.
To_solve this we_will use:
public virtual void SetSite(Object pUnkSite)
__  {

#if_DEBUG
__ _  __Debugger.Launch();
#endif

 __    ... Other_code...
_   }

This ensures that the_debugger gets attached early_on_in the BHO lifecycle._Read about the nitty gritty_details here.
Pressing F5 now will result_in a_few dialogs_asking you which debugger to attach:

From thereon out it' s happy_debugging:

I hope this helps!
EDIT
I recently was_asked to bring some_updates to_a_rather ancient BHO_I_wrote. Revisiting_my own tutorial, I noticed some issues_might come_up when following it:
1) After quickly_deploying a W7 machine_with_VS2010 (as released) I got a_funky error when an attempt was_made to attach the debugger:

I_could_resolve_the issue by also installing_VS2010 SP1 (as I used it_originally) although I_have no clue why this was happening.
2)_Right_now, when an attempt is made_to_attach the debugger, the instance of_VS2010_holding_my project is not in_the list of available debuggers.

However, when_I just cancel all dialogs and restart IE, the_running instance is_magically there and I can_hit_my_breakpoints once again