Sometime, failing to launch VS in an "administrator" mode would be a costly mistake while compiling. When you compile Office related Addin, it shows a message asking to relaunch or "Run as Administrator" but for certain project types, it throws a weird AV exceptions. Recently, I was trying to setup hands on for service fabric samples but got a bunch of errors when compiling. Tried as administrator mode worked fine. Later I learned that, why not set to run as admin always. Below is the step,
Right click Visual Studio shortcut > Properties > Advanced > check the "Run as administrator". Now, you will notice your VS instance launched under "admin" mode.
See you later.