Using .NET Assemblies


The capability to reuse code written in other languages is the hallmark of COM and its successor, .NET. While you can only write SSIS scripts using Visual Basic.NET, you can reuse assemblies created using any .NET language including C#, J#, and even Delphi.

Using assemblies gives you the ability to reuse your existing code. You may have already written code that performs data validation; now you can reuse it in your SSIS package. No sense in rewriting code that is already tested and in use.

To use an assembly in your script, you must reference it. To reference it, in turn, you must put it in a location accessible to SSIS. SSIS can only use assemblies located in the .NET framework installation folder for version 2.0.

To add a reference, you must be in the Visual Studio for Applications environment for editing your script code. Go to the Project menu and select Add Reference. The Add Reference window will appear as shown in Figure 7-17.

image from book
Figure 7-17

Select the assemblies from the list that you wish to reference and click the Add button. They will be added to the component list. Once you're done, click OK to add the references to your project. Now you can use any objects located in the referenced assemblies just like any other object.

Alternatively, you can add and remove references using the Project Explorer. Expand the References node to see all the references in your project. Right-click a reference and select Remove to remove it from the project. To add a reference, right-click the References node and select Add Reference to bring up the Add Reference window.

Open your HelloWorld package and edit the Script task. Add a reference to the System.Xml.dll by bringing up the Add Reference dialog, selecting the library from the list, and clicking Add. Click OK to close the dialog.

You can now use all the classes in the System.Xml namespace, and the VSA editor will provide full IntelliSense as with all the other objects.



Professional SQL Server 2005 Integration Services
Wireless Java : Developing with Java 2, Micro Edition
ISBN: 189311550X
EAN: 2147483647
Year: 2006
Pages: 182

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net