Referencing Other Assemblies in Scripting Solutions
Aktualisiert: 14. April 2006
The Microsoft .NET Framework class library and the Microsoft.VisualBasic namespace provide the script developer with a powerful set of tools for implementing custom functionality in Integration Services packages. The Script task and the Script component can also use custom managed assemblies.
Using a Custom Managed Assembly
The .NET tab of the Add Reference dialog box in Microsoft Visual Studio for Applications lists the managed assemblies found in the %windir%\Microsoft.NET\Framework\v2.0.xxxxx folder and the %ProgramFiles%\Microsoft SQL Server\90\SDK\Assemblies folder. Therefore, by default, this list is largely limited to assemblies from the Microsoft .NET Framework class library and assemblies installed by SQL Server 2005. The contents of the list are determined exclusively by file location and not by installation in the global assembly cache (GAC) or by other assembly attributes or properties. As a result, a copy of any assembly that you want to reference needs to be present in one of the specified folders. The Add Reference dialog box in VSA does not include the Browse button that is present in Microsoft Visual Studio for locating and referencing managed assemblies in other folders, and does not include the COM tab for referencing COM components.
A custom assembly that you want to use in the Script task or the Script component must also be signed with a strong name and installed in the global assembly cache.
When you deploy a package that uses a custom assembly to another computer, you must install the assembly in the global assembly cache. If the script is not precompiled, you must also copy the assembly into the Framework folder or the Assemblies folder as described above for adding a reference.
Using a Web Service
Visual Studio for Applications does not have the Add Web Reference command that is familiar to Visual Studio developers. If you want to use a Web service from the Script task or from the Script component, you must first use the command prompt utility wsdl.exe to generate a proxy class in Visual Basic. Then you have two options:
- Import the proxy class file into the VSA project by using the Add Existing Item option.
- Build the proxy class into a separate assembly that is signed with a strong name key file, copy the assembly to the Framework folder as described above, add it to the global assembly cache, and then add a reference to the assembly in the VSA project. In this case, you need to deploy the additional assembly along with your package.
You must also add a reference in the script project to the System.Web.Services namespace.
For more information about generating the proxy class, see the following topics in the MSDN Library:
- Creating an XML Web Service Proxy
- How to: Generate an XML Web Service Proxy
- Web Services Description Language Tool (Wsdl.exe)
Using the Microsoft.VisualBasic Namespace
The Script task and the Script component can use Microsoft Visual Basic .NET objects and functions from the Microsoft.VisualBasic namespace. The VisualBasic namespace contains many of the objects, functions, and constants from earlier versions of Visual Basic, and a wide variety of useful functions. The Microsoft.VisualBasic.Financial module, for example, contains methods for calculating depreciation, internal rate of returns, and annuity payments.
Using the Microsoft .NET Framework Class Library
The Script task and the Script component can also take advantage of all the other objects and functionality exposed by the Microsoft .NET Framework class library. For example, by using the .NET Framework, you can retrieve information about your environment and interact with the computer that is running the package.
This list describes several of the more frequently used .NET Framework classes:
- System.Data Contains the ADO.NET architecture.
- System.IO Provides an interface to the file system and streams.
- System.Windows.Forms Provides form creation.
- System.Text.RegularExpressions Provides classes for working with regular expressions.
- System.Environment Returns information about the local computer, the current user, and computer and user settings.
- System.Net Provides network communications.
- System.DirectoryServices Exposes Active Directory.
- System.Drawing Provides extensive image manipulation libraries.
- System.Threading Enables multithreaded programming.
For more information about the .NET Framework and the Microsoft Visual Basic runtime library, see the MSDN Library.
Change History
Release | History |
---|---|
14. April 2006 |
|