PRB: assemblies, ?? ????? ?? XSLT ??? ????????? ?? ????? ?? ??? ????? ???? ?? ????

???? ?????? ???? ??????
???? ID: 316775 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? ???? ???????? ?? ???? ??? ??. ??? "???? ??" ???? ?? ?????????? ???? ??? ?? ?? ?? ??????? ???? ???? ?????.
?? ???? ????? Microsoft ?? ???????? ???? ?????? ????????? ????? ????????? ????????:
  • System.IO
  • System.Xml
  • System.Xml.XPath
  • System.Xml.Xsl
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

?????

?? <msxsl:script> ???? ??? ??? ?? System.Xml.Xslt ????? ?? ??? ????? ???? ???, ?? ?????? ????? ???? ???? ??????? ??????????? ??????? ???? (XML) ?? ??????????? ???? ????? ???? (XSL) ????????? ?? ???? ??? </msxsl:script>

????

?? ??????? System.Xml ???????? ?????? ???????? XSL ???????????????? (XSLT) ??????????? ??? ????????? ???? ?? ????? ?? ???????????? ?? ?????? ?????, <msxsl:script> ???? ???? ???????????? ???? (???? ?? Microsoft Visual C#. ????? ???? ?? ??? ???? ????? ?? Microsoft Visual Basic.??? ???????. ???? ?? ??? ???)</msxsl:script>

Declared ??????? ????????? ????? ?? ???? ???? ???? ??? XSL ????? ?? ??? ???????? ????????? ?? ????? ???? ???, ?? Microsoft ??????? ???? (MSIL) ??? ?? ??????? ?? ????? ?? ?????? ??? ???? Microsoft ?? ?? ??????? ??? ??????? ??? ?? ???????? ?????, ?? ?? ??????? ?????? ?? ????? ???? ?? ????? ?? ?? assemblies ????? ?? ?? ??? ??? ?? ?? ??? ??? ??? ???? ?? ??? ?? ?????? ????? ?? ?? ???? ???

????????

?? ?????? ?? ?? ???? ?? ???, ???-??? XSLT ????????? ?? ??? ??? ????? ?? ?? ??? XSLT ??? ?? ?? ??? ?? ??? ??? ?? ??? ??? ?? ???????? ?? ???? ????? ??? ???? ??? ???? ????????? ??????? ?? ?????? ?? ??????????? ?? ??????? ???

?????? ?? ???, ????? ??? ?????? leaks:
For(int i=0;i<1000;i++)
{
      xslt.Load(stylesheet);
      //Do other stuff
      xslt.Transform(doc, null, writer);
}
				
????? ??????????? XSLT ?? ???? ?? ??? ??? ?? ??? ??? ???: ????? ???? ?? ??? ???:
xslt.Load(stylesheet);
For(int i=0;i<1000;i++)
{

      //Do other stuff
      xslt.Transform(doc, null, writer);
}
				
?? ??? ???? ?? ??? ??????? ??? ?? ???? ?? ?? ?????? ???? leak.

????? ?????????

???-??? ??????? ??????? ?????? ??? ????????? ????? ???????? ?????? ??? ???? ?? ??? ??? AppDomain.Unload() ??? ??????? ?? ???????? ????????? ????? ?? ??? ???? ?? ??? UnloadDomain() ????????? ???????? API ?? ?????

???? ???????

??????? ?? ???: ??????? ???? ?? ??? ???

  1. ???? Visual C# ??????????????? ??? ????? ??????????
  2. XSLT ????????? ?????, ?? ???? ??? ?????????? ??? ??????:
    using System;
    using System.IO;
    using System.Xml;
    using System.Xml.XPath;
    using System.Xml.Xsl;
    
    public class Sample
    {
    	private const String filename = "..\\..\\XmlFile1.xml";
    	private const String stylesheet = "..\\..\\XSLTFile1.xslt";
    
    	public static void Main() 
    	{
    
                    for(int i=0;i<1000;i++)
                    {
    
    		XslTransform xslt = new XslTransform();
                    xslt.Load(stylesheet);
    
    		//Load the XML data file.
    		XPathDocument doc = new XPathDocument(filename);
    
    		//Create an XmlTextWriter to write to the console.         
    		XmlTextWriter writer = new XmlTextWriter(Console.Out);
    		writer.Formatting = Formatting.Indented;
    
    		//Transform the file.
    		xslt.Transform(doc, null, writer);
    		writer.Close();
                    }
    		System.Console.Read();
            
    	} 
    }
    					
  3. XSLTFile1.xslt ???? XSLT ????? ?????, ?? ???? ??? ?????????? ??? ??????:
     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        xmlns:user="urn:my-scripts">
    
      <msxsl:script language="C#" implements-prefix="user">
    
    <![CDATA[
    
         public double circumference(double radius){
           double pi = 3.14;
           double circ = pi*radius*2;
           return circ;
         }      
                ]] >     
    <!-- Remove the space between ]] and > in the preceding line. -->
    <!-- The space is inserted because of a publishing constraint. -->
    
       </msxsl:script>
    
      <xsl:template match="data">  
      <circles>
    
      <xsl:for-each select="circle">
        <circle>
        <xsl:copy-of select="node()"/>
           <circumference>
              <xsl:value-of select="user:circumference(radius)"/>        
           </circumference>
        </circle>
      </xsl:for-each>
      </circles>
      </xsl:template>
    </xsl:stylesheet>
    					
  4. XMLFile1.xml ??? XML ????? ?????, ?? ???? ??? ?????????? ??? ??????:
    <?xml version='1.0'?>
    <data>
      <circle>
        <radius>12</radius>
      </circle>
      <circle>
        <radius>37.5</radius>
      </circle>
    </data>
    					
  5. XML ?? XSL ??????? ?? ????????? ??????? ??? ???????
  6. ??? ?? ?????? ?? ???? ????? ????? ??? ?? assemblies ????? ?? ?? ????? ???????? ?? ?????? ????? ??? ????????
  7. ??????????? ??????? ?????? ???? ?????? ?????? ?????? ??? ????????? ?? ????? ????

???

???? ID: 316775 - ????? ???????: 24 ????? 2014 - ??????: 1.0
???? ???? ???? ??:
  • Microsoft .NET Framework 4.0
  • Microsoft .NET Framework 2.0
  • Microsoft .NET Framework 1.0
??????: 
kbnosurvey kbarchive kbprb kbmt KB316775 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:316775

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com