Visual article describes how to use visual c#.net to create a DTS customization task. You can extend DTS functionality in a way that c#.net create custom tasks. You can then install and register the task, and he speaks the DTS design which is now, like the default DTS task. In short, you can use the. NET framework to create a custom task.
In addition to creating a DTS Customization task in this article, there are some things to include:
1, the custom code in this article is divided into compiling, registering and installing custom tasks;
2, this part of a distinctive part is that you can run a custom task;
3, in the development process you can use some of the tools mentioned in this article (unless otherwise noted, these tools are already included in the. NET, you can pass. NET to run these tools on the command line.
Create a timely package for DTSSpkg.dll
If one is based on Microsoft. NET client to access a COM component, you must use a package (which the component contains). This kind of package is a just-in-time running package (RCW) and you can also compile it through an open Dtspkg.dll type library. You can also compile the RCW using the Type Library Export tool (Tlbimp.exe), such as:
The "/keyfile" parameter represents Microsoft.SQLServer.DTSPkg80.dll with a strong type name with public or private keywords. Use the strongly typed name tool (Sn.exe) to create a keyword before dtspkg.snk:
Sn.exe–k DTSPkg.snk
You should use a strongly typed name like the other global collection cache because you installed the run package.
Installing the run package in the Global collection cache
To install the run package with the Global Collection Cache tool (GaCutil.exe):
gacutil.exe/i Microsoft.SQLServer.DTSPkg80.dll
After installing the run package, you can add it like. Netc# the same additions as references in the project.
Add code for a custom task
Custom registration for code. NET does not open Dllreginsterserver and dllunregisterserver like COM components, but you can use the ComRegisterFunctionAttribute class to perform task registration and unregister. Add the following code before customizing the class declaration:
The following code is an example of a function registration execution. The entire code of the function is in the compilation, registration, and Installation section of the custom task.
10020200-EB1C-11CF-AE6E-00AA004A34D5 is the class number of the DTS package object. Because all custom tasks perform custom interfaces, they must be registered. The registration function adds the following registry key value:
The following code demonstrates the execution of a task that is not a registered function. The face registration function is part of the Comunregisterfunctionattribute class in the. NET Runtime. To view the complete code for this function, you can see the "compiling, registering, and Installing Custom Tasks" section:
Finally, custom tasks are opened like dual_interface COM components. You create a default interface from all of the class's public, Non-static fields, properties, and methods. After the following line of code is applied using the custom task source file:
This part of the code has been completely enumerated.
Add Functional Customization Tasks
The "compiling, registering, and Installing custom Tasks" section of this article contains a simple DTS custom task code. The task has two properties: the value of the Name and Description,description property appears in the message box. This example describes a minimized code that you can use to define tasks with existing functional DTS. However, you can create a user interface by executing the CustomTaskUI interface, but that is not discussed. The DTS Designer creates a default user interface for custom tasks by executing only custom interfaces.
All DTS customization tasks perform custom task interfaces. A custom user interface is made up of two properties, a collection, and a method:
1, name and description attributes;
2, properties set;
3, execute method.
All custom tasks should perform properties, property sets, and Execute methods.
Compiling, registering, and installing custom tasks
Using System;
Using System.Runtime.InteropServices;
Using Microsoft.SQLServer.DTSPkg80;
Using Microsoft.Win32;
Using System.Windows.Forms;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.