Profile optimization is having no effect because the call to System.Runtime.ProfileOptimization.SetProfileRoot is being with the location of the executable as the directoryName. It should in fact be the name of the directory where the executable is located.