Roslyn XsltCompile issues

I recently was in the process of upgrading a VS2013 project to VS2015.  I created a new VB Web Application project and it addded the Roslyn compiler components.

In the project were several xsltCompiledTransform calls. There were no compile errors, but during runtime when the xslt.Load method was called, an error was raised:

Exception Details: System.Xml.Xsl.XslLoadException: Type 'Global.System.Web.HttpRequest' is not defined.

It took me a while to figure out that the xslt sheet contained a <msxsl:script language="VB" implements-prefix="VB">  element that was compiled during runtime. I was able to track down the compile files in %user%/AppData/temp.  The compiling was using the Roslyn compilers but for some reason the System.Web assembly was not loaded during the compilation.

So how to fix this error?  I found several ways.
1.  Remove the Roslyn compiler from the web.config.  Comment out the <system.codedom> element and the run time compiler will use the old .Net Framework compiler.
2.  Add  <msxsl:assembly name="System.Web"/> to the msxsl:script element
3. Add "/R System.Web.dll" to the web.config compiler compilerOptions.


Print | posted on Wednesday, November 23, 2016 2:56 PM