diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index f23ec97119f5b3db70674370f1fa43902484a319..94b39e951a5a324b5533bd755c809d694b67e120 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -113,6 +113,8 @@ class TemplateLayout extends \OC_Template {
 				$this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
 			} catch (\OCP\AppFramework\QueryException $e) {
 				$this->assign('themingInvertMenu', false);
+			} catch (\OCP\AutoloadNotAllowedException $e) {
+				$this->assign('themingInvertMenu', false);
 			}
 
 		} else if ($renderAs === 'error') {