This is kind of of a weird error and it didn't make sense to me at first (still doesn't really). The best workaround I could find on the net was to temporarily change the application to run in the application pool of the central admin site.
Steps:
- Change the AppPool for the app to be the same as the Central Admin site (Home Directory tab in IIS website properties).
- Reset IIS or at the very least do an %systemroot%\system32\iisapp.vbs /a "apppoolname" /r (not sure if the iisapp.vbs method will work but cant see why not).
- Activate the publishing infrastructure.
- Set the app pool back to normal.
- repeat step 2.
Enjoy!