Use C #. NET to create a DTS custom task

Source: Internet
Author: User
Tags microsoft sql server

This 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:

Tlbimp.exe "C:\ProgramFiles\Microsoft Sqlserver\80\tools\binn\dtspkg.dll"/out:microsoft.sqlservver.dtspkg80.dll/ Keyfile:DTSPkg.snk

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:

[Guid("A39847F3-5845-4459-A25E-DE73A8E3CD48"), ComVisible(true)]
[ProgId("DTS.SimpleTask")]
public class SimpleTask : CustomTask
{
//implementation of custom task
}

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.

[System.Runtime.InteropServices.ComRegisterFunctionAttribute()]
static void RegisterServer(Type t)
{
//code to register custom task
}

The registration function adds the following key value for registration.

Hkey_classes_root\clsid\a39847f3-5845-4459-a25e-de73a8e3cd48\implemented categories\{10020200- EB1C-11CF-AE6E-00AA004A34D5}

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:

HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL server\80\dts\enumeration\tasks\ A39847f3-5845-4459-a25e-de73a8e3cd48

The following DTS task caches a list of directories so that customized tasks appear in DTS Designer:

HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL server\80\dts\enumeration\tasks\

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.