Package.LoadFromXML(String, IDTSEvents) Package.LoadFromXML(String, IDTSEvents) Package.LoadFromXML(String, IDTSEvents) Method

정의

메모리에 XML 형식으로 저장된 패키지 및 모든 해당 개체를 로드합니다. Loads a package and all its objects that have been saved to memory in XML format. 하드 드라이브에 저장된 패키지를 로드하려면 LoadPackage(String, IDTSEvents) 메서드를 사용합니다. To load a package that is saved to the hard drive, use the LoadPackage(String, IDTSEvents) method.

public:
 void LoadFromXML(System::String ^ packageXml, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events);
public void LoadFromXML (string packageXml, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events);
Public Sub LoadFromXML (packageXml As String, events As IDTSEvents)
매개 변수
packageXml
String String String

XML 형식의 패키지가 포함된 String입니다. A String that contains the package in XML format.

events
IDTSEvents IDTSEvents IDTSEvents

구현 하는 개체는 IDTSEvents 지속 중 이벤트 (오류, 경고 및 등)를 발생 시키기 위한 인터페이스입니다. An object that implements the IDTSEvents interface for firing events (errors, warnings, and so on) during persistence.

예제

다음 코드 예제에서는 패키지를 만들고 두 작업을 추가 합니다.The following code example creates a package and adds two tasks to it. XML에 저장 된 패키지는 XmlDocument 메모리에 있습니다.The package XML is saved to an XmlDocument in memory. 두 번째 패키지를 만드는 그룹과 동일한 로드 되기 때문에 및 XmlDocument, 첫 번째 패키지의 중복 되었습니다.A second package is created, and because it is loaded with the same XmlDocument, it is now a duplicate of the first package.

using System;  
using System.Collections.Generic;  
using System.Text;    
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;  
using System.Xml;  

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application app = new Application();  

            // Location and file name can be combined into one string,   
            // or location could be set by a variable instead of   
            // hard-coded.  
            String XmlLocation = @"C:\XML";  
            String XmlFileName = "TestXML.xml";  
            String XmlFile = XmlLocation + XmlFileName;  
            Package pkg = new Package();  
            pkg.CreatorName = "Test";  
            pkg.Name = "SaveToXML Package";  
            pkg.CheckSignatureOnLoad = true;  
            pkg.DelayValidation = false;  
            pkg.SaveCheckpoints = false;  

            // Create package XmlDocument and use in pkg.SaveToXml.  
            XmlDocument myPkgDocument = new XmlDocument();  
            pkg.SaveToXML(ref myPkgDocument, null, null);  
            // If you want to see what the package XML contains   
            // at this point, uncomment this line and view the console.  
            // Console.Out.WriteLine(myPkgDocument.OuterXml);  

            // Now modify the package. Create a task   
            // and set some properties.  
            Executable execBI = pkg.Executables.Add("STOCK:BulkInsertTask");  
            TaskHost th = execBI as TaskHost;  
            th.Properties["DebugMode"].SetValue(th, false);  

            // Save the task into the package using pkg.SaveToXML.  
            // This saves the package after it has been modified  
            // by the addition of the task.  
            pkg.SaveToXML(ref myPkgDocument, null, null);  

            // When you want to save the package to the hard-drive,  
            // Save using the Application.SaveToXML method.  
            //app.SaveToXml(XmlFile, pkg, null);  

            // Reload the package from its XML.  
            Package pkg2 = new Package();  
            pkg2.LoadFromXML(myPkgDocument, null);  
            Console.WriteLine("This is the package XML that pkg2 now contains:");  
            Console.Out.WriteLine(myPkgDocument.OuterXml);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text    
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask  
Imports System.Xml  

Namespace Microsoft.SqlServer.SSIS.Samples  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   

            ' Location and file name can be combined into one string,   
            ' or location could be set by a variable instead of   
            ' hard-coded.  
            Dim XmlLocation As String =  "C:\XML"   
            Dim XmlFileName As String =  "TestXML.xml"   
            Dim XmlFile As String =  XmlLocation + XmlFileName   
            Dim pkg As Package =  New Package()   
            pkg.CreatorName = "Test"  
            pkg.Name = "SaveToXML Package"  
            pkg.CheckSignatureOnLoad = True  
            pkg.DelayValidation = False  
            pkg.SaveCheckpoints = False  

            ' Create package XmlDocument and use in pkg.SaveToXml.  
            Dim myPkgDocument As XmlDocument =  New XmlDocument()   
            pkg.SaveToXML( myPkgDocument,Nothing,Nothing)  
            ' If you want to see what the package XML contains   
            ' at this point, uncomment this line and view the console.  
            ' Console.Out.WriteLine(myPkgDocument.OuterXml);  

            ' Now modify the package. Create a task   
            ' and set some properties.  
            Dim execBI As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask")   
            Dim th As TaskHost =  execBI as TaskHost   
            th.Properties("DebugMode").SetValue(th, False)  

            ' Save the task into the package using pkg.SaveToXML.  
            ' This saves the package after it has been modified  
            ' by the addition of the task.  
            pkg.SaveToXML( myPkgDocument,Nothing,Nothing)  

            ' When you want to save the package to the hard-drive,  
            ' Save using the Application.SaveToXML method.  
            'app.SaveToXml(XmlFile, pkg, null);  

            ' Reload the package from its XML.  
            Dim pkg2 As Package =  New Package()   
            pkg2.LoadFromXML(myPkgDocument, Nothing)  
            Console.WriteLine("This is the package XML that pkg2 now contains:")  
            Console.Out.WriteLine(myPkgDocument.OuterXml)  
        End Sub  
    End Class  
End Namespace  

설명

사용 해야는 LoadFromXML 메서드를 메모리에 있는 XML을 로드 합니다.You should use the LoadFromXML method to load the XML that is in memory. XML을 사용 하 여로 하드 드라이브에 저장 된 패키지를 로드 하려는 경우는 Microsoft.SqlServer.Dts.Runtime.Application.LoadPackage 메서드.If you want to load a package that has been saved to the hard drive as XML, use the Microsoft.SqlServer.Dts.Runtime.Application.LoadPackage method. 사용 하 여 패키지 어 파일 시스템 또는 MSDB 데이터베이스에 저장 하는 경우는 Microsoft.SqlServer.Dts.Runtime.Application.LoadFromSqlServer 또는 Microsoft.SqlServer.Dts.Runtime.Application.LoadFromDtsServer 메서드.If the package has been saved to the File System or MSDB database, use the Microsoft.SqlServer.Dts.Runtime.Application.LoadFromSqlServer or Microsoft.SqlServer.Dts.Runtime.Application.LoadFromDtsServer methods.

호출 하는 경우 로드 메서드 중 하나에 Application, 런타임은 작업, 연결 관리자, 로그 공급자, 반복 및 패키지 및 호출 하 여 포함 된 다른 모든 개체는 LoadFromXML 메서드는 각각에 대해 합니다.When you call any of the loading methods on the Application, the runtime will iterate through the tasks, connection managers, log providers, and all other objects that are contained by the package and call the LoadFromXML method on each of them. 포함 된 개체 코드가 있는 자신의 LoadFromXML 구문 분석 하는 XmlElement 개체가 다시 만들어야 하는 각 속성과 요소에 대해 저장 된 값에 대 한 합니다.The contained objects have code in their LoadFromXML that parses the XmlElement for each property that the object must recreate, and the value saved for the element. 따라서 호출 하지 않으면 직접는 LoadFromXML 개별 개체에 하지만에서 메서드를 호출는 Application 개체 및 런타임 패키지 및 호출을 통해 연계 됩니다는 LoadFromXML 있습니다에 대 한 개체에 있습니다.Therefore, you do not directly call the LoadFromXML on the individual objects, but call the method on the Application object, and the runtime will cascade through the package and call the LoadFromXML on the objects for you.

적용 대상