Exception “stylesheet is too complex” when loading large XSLT
An exception "The stylesheet is too complex" when attempting to load an XSLT stylesheet in .NET 4.0.
Solution
Adding the following setting to your config file and the problem should go away.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="system.xml">
<section name="xslt" type="System.Xml.XmlConfiguration.XsltConfigSection, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.xml>
<xslt limitXPathComplexity="false"/>
</system.xml>
</configuration>