Creating Pipeline Components Using C#

You can create pipeline components using C#.

To create a pipeline component using C#

  1. Start Visual Studio .NET.
  2. Open a new C# Class Library project.
  3. When you are in the project, in the solution explorer, right-click the project, and then click Properties.
  4. In the <project> Properties dialog box, highlight configuration properties, and then set “Register for COM interop” to True.

Visual Studio.NET automatically registers the component with COM.

Now that you have set up the C# Class Library project, you are ready to implement the Pipeline interfaces.

To implement the Pipeline interfaces

  1. Add the Pipecomplib reference to the C# project. Pipecomplib is the Primary Interop Assembly (PIA) that contains the definition of the pipeline interfaces.

  2. Add the following using statements:

    using System.Runtime.InteropServices;
    using Microsoft.CommerceServer.Runtime;
    using Microsoft.CommerceServer.Interop;
    using Microsoft.CommerceServer.Interop.Orders;
    
  3. Inherit the component from IPipelineComponent. Optionally, you can inherit the component from IPipelineComponentDescription and IPipelineComponentAdmin.

  4. To automatically implement stubs for the interface methods by Visual Studio .NET, do the following:

    1. On the Tools menu, click ClassView.
    2. On the Class View tab, expand the class and then select Bases and interfaces.
    3. Right-click the interface, click Add, and then click Implement Interface.
  5. Assign the component a globally unique identifier (GUID).

    Caution   If you do not perform this step, Visual Studio .NET will assign a new GUID each time you rebuild the component.

  6. To assign a GUID, put a GUID attribute before the class as follows:

    [GuidAttribute("60D1C320-0B20-4e97-8F98-F301524E81B3")]
        public class MyPipeComp: IPipelineComponent, IPipelineComponentAdmin, IPipelineComponentDescription
    

Note   The GUID must be unique (the above GUID is an example). Use the following procedure to create a new GUID.

To create a new GUID

  1. On the Tools menu, click Create GUID.
  2. Click Registry Format, and then click Copy.
  3. Paste the GUID into the GuidAttribute as shown in the above example.

We recommend that you configure the assembly to be signed with the private key of your organization. To sign the assembly with the private key of the organization, set the AssemblyKeyFile attribute in the AssemblyInfo.cs file.

You register the component as a pipeline component by using the Pipeline Component Registration tool. For information about using the Pipeline Component Registration Tool, see Using the Pipeline Component Registration Tool.

To register the component as a pipeline component

  1. Click Start, point to Programs, point to Microsoft Commerce Server 2002, and then click Software Development Kit.

  2. In Windows Explorer, locate <drive>:\Program Files\Microsoft Commerce Server\SDK\Tools\Registration Tool.

  3. Double-click PipeReg.exe.

    The Pipeline Component Registration Wizard appears.

  4. On the Step 1 of the Pipeline Component Registration Wizard page, click Select component Type Library to locate the .tlb file generated for your pipeline component by Visual Studio .NET (for example, in the bin\debug folder), and then click Next.

  5. On the Step 2 of the Pipeline Component Registration Wizard page, click Available Categories to select the stage(s) of the pipeline or click All Stages, and then click Next.

  6. On the Step 3 of the Pipeline Component Registration Wizard page, click Register and export data to select a file path for the .reg file, and then click Next.

  7. On the Pipeline Component Registration Wizard [Finished] page, click Close.

To deploy the pipeline component

  • Copy the assembly to the target computer and register the component with the Register Assembly Utility (regasm.exe), which is part of the .NET Framework SDK.

    Note   We recommend that you use Gacutil.exe to register the component into the global assembly cache (GAC). Installing assemblies in the GAC requires them to be strongly named. If you are not deploying the component into the GAC, then using the /codebase option of regasm is required in order for COM to be able to locate your component.

If you need to debug your component, copy the PDB symbols into the same location where you registered the pipeline component.

The following is a C# template for creating a pipeline component, without using the Visual Studio .NET user interface:

using System;
using System.Runtime.InteropServices;
using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Interop;
using Microsoft.CommerceServer.Interop.Orders;

namespace Commerce

{
 [GuidAttribute("7BB430D4-5DD0-4ed9-B453-A93AB813E540")]

 public class CSharpTemplate : IPipelineComponentAdmin,
                                IPipelineComponent,
                                IPipelineComponentDescription,
                                IPersistDictionary
  {
    public CSharpTemplate(){this.InitNew();}
    public String GetProgID(){return null; }
    public void InitNew(){}
    public Int32 IsDirty(){return 0; }
    public void Load(Object pDispDict){}
    public void Save(Object pDispDict, Int32 fSameAsLoad){}
    public Int32 Execute(Object pdispOrder, Object pdispContext, Int32 Flags){return 0;}
    public void EnableDesign(Int32 fEnable){}
    public Object GetConfigData(){return null;}
    public void SetConfigData(Object pdispDict){}
    public System.Object ContextValuesRead(){return null;}
    public System.Object ValuesRead(){return null;}
    public System.Object ValuesWritten(){return null;}
  }
}

Copyright © 2005 Microsoft Corporation.
All rights reserved.