Running VSTO Addins From Visual Studio Leaves Residual Code Behind

[2 minute read]

I just lost 60 minutes of my life… and I’m never getting it back.

About a year ago my dad asked me to write him an Excel addin that would shuffle some data around, do some minor aggregations, yadda yadda yadda. Nothing major. Being the good son I am, I got started right away. Gosh, I’m great! But then, being the bad son I am, I got distracted and never quite finished it. Every few months he’d gently remind me about the software I’d promised him: “Hey WTF! Where’s that program you promised me three months… six months… a year ago?!” (Don’t worry; we like to give each other shit. It’s just our way.) I’d be all embarrassed, but still managed to put it off repeatedly. Oh, work’s killing me… oh, I have a skydiving obligation… oh, yeah, I’ll get to that. Rotten son.

Finally today I decided to pick up where I left off. I looked at my VBA of yore and I thought Ooh, be nice to move this to a C# VSTO addin that I could deploy online and let ClickOnce handle any code changes I make. Boy am I glad I tried to deploy a Hello World app before I did anything else. I ran the (Hello World) addin from Visual Studio and it worked as expected but—surprise, surprise—there are security restrictions when installing an addin from the internet and I don’t feel like spending the time figuring it all out. Dad’s addin should be a one and done type deal anyways.

So I closed Visual Studio and went back to my VBA. I noticed that my hello world message box still appeared. Why? I never successfully installed the addin. Or did I? I look everywhere for an install folder to no avail. It’s not listed in my Add/Remove programs dialog either. How do I remove this stupid thing? And how did it get installed in the first place? I search around StackOverflow for an answer. No luck. Then I try google and finally I found a post by the famous Cindy Meister who was responding to another poor sap with the same issue.

The solution? CLEAN my addin project. No more hello world. Building the project registered the addin. Cleaning unregisters it.

Oh.

Well, now that that mystery is solved, I can finally wrap up my original code and move the needle on the Good-Son-O-Meter back to Practically Perfect In Every Way.