Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:39:21+00:00 2026-06-13T22:39:21+00:00

I have some code which is throwing an XslTransformException. This is the desired behavior

  • 0

I have some code which is throwing an XslTransformException. This is the desired behavior (the XSL contains an xsl:message element with @terminate set to yes).

I’m trying to catch this exception in my code, but can’t find the assembly containing this exception’s class, and can’t find any documentation on this exception in MSDN to get an idea of a suitable inherited class (i.e. to avoid using the class Exception in my catch block).

I’ve got the System.Xml and Sytem.Xml.Linq assemblies referenced and have the following using statements:

using System.Xml;
using System.Xml.Xsl;

The exception is in the System.Xml.Xsl namespace; i.e.:

System.Xml.Xsl.XslTransformException

Any idea which assembly I need to reference?

EDIT:
As requested, please find below sample code to reproduce this exception:

using System;
using System.Xml;
using System.Xml.Xsl;
using System.Text;

namespace StackOverflowDemo
{
    class Program
    {
        static void Main(string[] args)
        {

            XmlDocument xmsl = new XmlDocument();
            xmsl.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" exclude-result-prefixes=\"msxsl\"><xsl:output method=\"xml\" indent=\"yes\"/><xsl:template match=\"@* | node()\"><xsl:message terminate=\"yes\">this should throw an exception</xsl:message><xsl:copy><xsl:apply-templates select=\"@* | node()\"/></xsl:copy></xsl:template></xsl:stylesheet>");

            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load(xmsl.CreateNavigator());

            XmlDocument xml = new XmlDocument();
            xml.LoadXml("<root />");

            StringBuilder sb = new StringBuilder();
            XmlWriter writer = XmlWriter.Create(sb);
            /*
            try
            {
            */
                xsl.Transform(xml.CreateNavigator(), writer);
            /*
            }
            catch(XslTransformException e) //<-- this class does not exist
            {
                Console.WriteLine(e.ToString());
            }            
            */
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:39:23+00:00Added an answer on June 13, 2026 at 10:39 pm

    Adding the following catch block reveals all:

    catch (Exception e)
    {
        var t = e.GetType();
        while (t != null)
        {
            Console.WriteLine(t.AssemblyQualifiedName);
            t = t.BaseType;
        }
    }
    

    Output:

    System.Xml.Xsl.XslTransformException, System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    System.Xml.Xsl.XsltException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    System.SystemException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    

    I would ignore the XslTransformException though – you should catch XsltException instead. After all, that’s what XslCompiledTransform.Transform is documented to throw.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some fairly simple code using Protobuf.net, which is throwing a very odd
I have some code which takes strings representing hexadecimal numbers - hex colors, actually
I have some code which I want to document with in-body comments like so:
I have some code which I'm currently using to change the static-IP of a
I have some code which populates a hashtable with a question as the key
I have some code which handles data files and reports an error when it
We have some code which sorts a list of addresses based on the distance
I have some code which is built both on Windows and Linux. Linux at
I have some code which builds an array of date ranges. I then call
I have some code which I think has extra release statements. Is the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.