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 782589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:24:33+00:00 2026-05-14T20:24:33+00:00

I have a component written in C#. Among other things it performs XSL transform

  • 0

I have a component written in C#. Among other things it performs XSL transform on XML data it collects. When I test this feature using another C# project that uses the component it works just fine. However when I export the component as a COM component and try to use this feature from an application it fails on the XslCompiledTransform.Load command with an XSLT compile error.

Here is the C# code: (click_me)

And the error I am getting is copied in a file. Please find it here: (click_me)

The XSLT file along with the number of templates also consists of “C# script” meant for some advanced calculations, which XSLT isn’t capable of.

Here is the typical XSL code that I use:

<?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" xmlns:cs="urn:cs">
  <xsl:output method="xml" indent="no"/>

  <msxsl:script language="C#" implements-prefix="cs">
    <![CDATA[
     private static string[] formats_datetime = new string[]
     {
        "MM/dd/yyyy HH:mm:ss"
     };

     public string date_add(string date_str, string time_span_par)
      {
            DateTime date_value;
            TimeSpan time_span_var = TimeSpan.Parse(time_span_par);

            DateTime.TryParseExact(date_str, formats_datetime, new global::System.Globalization.CultureInfo("en-US"), global::System.Globalization.DateTimeStyles.None, out date_value);
            date_value = date_value.Add(time_span_var);
            string temp = date_value.ToString("MM/dd/yyyy HH:mm:ss");
            return(temp);
      }
]]>
  </msxsl:script>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@*| node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="date_node">
    <xsl:variable name="date_in">
      <xsl:value-of select="."/>
    </xsl:variable>
    <xsl:variable name="period">
      <xsl:value-of select="'06:00:00'"/>
    </xsl:variable>
    <xsl:copy>
      <xsl:value-of select="cs:date_add($date_in, $period)"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

And the XML content:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <node1>34</node1>
  <node2>23</node2>
  <date_node>12/31/2020 23:59:59</date_node>
  <child>
    <node1>text</node1>
    <date_node>12/31/2020 23:59:59</date_node>
    <grand_child>
      <date_node>12/31/2020 23:59:59</date_node>
    </grand_child>
  </child>
</root>
  • 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-05-14T20:24:34+00:00Added an answer on May 14, 2026 at 8:24 pm

    I hope that replacing the inline scripts with calls to extension functions (methods of an extension object, that is passed to the transformation) will solve the problem.

    It is recommended to use extension functions in preference over inline scripts.
    If inline scripts are used extensively in an IIS server environment, this can result (and this has been observed) to memory leaks that eventually bring down the server. This is because the XslCompiledTransform compiles the scripts into dynamic dlls that cannot be unloaded until IIS is recycled.

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

Sidebar

Related Questions

I have a simple GUI component written in Java. The class draws an analog
I have written a new custom component derived from TLabel. The component adds some
We have a WinForms application written in C# that uses the AxAcroPDFLib.AxAcroPDF component to
I have a component which writes/generates javascript from a server side renderer. This component
I have a component which has a List<T> property. The class in the list
I have a custom component where I have implemented INotifyPropertyChanged and IBindableComponent . However,
I have an ascx component, that holds two-level menu, because there are several user
I have a .NET component exposed as a CCW (Com Callable Wrapper) and being
I have a visual component that I built from a TFrame (but then registered
I have a serviced component installed in a COM+ server application. I want to

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.