Search code examples
c#ssisscript-component

What does base.preexecute(); or base.postexecute() actually do?


When I create a new script component within SSIS, the preexecute and post execute methods contain the base.PreExecute(); and base.PostExecute(); lines...

I want to know what these lines do, and the ramification for modifying/removing them. Thanks!


Solution

  • tl;dr;

    For the current release of Integration Services, these are no-op methods. The current ramifications for removing them will be non-existent. However, Microsoft may at any time add an operation into these methods that is crucial to the well being of Integration Services (highly unlikely via patch, less so through the release of a new version). They have not done so for 2008, 2012 or 2014 but v.Next is unknown.

    Unless you have a strong reason to not spend the momentary flicker hitting the base method, I'd just leave it in there.

    l;r

    A Script Component, creates a ScriptMain class which is derived from UserComponent which is derived from ScriptComponent.

    UserComponent is auto generated by Visual Studio whenever you create/modify the inputs and outputs to a Script Component.

    /* THIS IS AUTO-GENERATED CODE THAT WILL BE OVERWRITTEN! DO NOT EDIT!
    *  Microsoft SQL Server Integration Services component wrapper
    *  This module defines the base class for your component
    *  THIS IS AUTO-GENERATED CODE THAT WILL BE OVERWRITTEN! DO NOT EDIT! */
    

    ScriptMain is your playground and where you can optionally call the base.pre/postexecute methods.

    Depending on your version, ScriptComponent, comes from Microsoft.SqlServer.TxScript.dll

    • C:\Program Files (x86)\Microsoft SQL Server\{VersionNumber}\DTS\PipelineComponents\Microsoft.SqlServer.TxScript.dll

    Hitting F12 on the Pre/PostExecute component takes me to

    public class ScriptComponent
    {
        public virtual void PostExecute();
        public virtual void PreExecute();
    }
    

    I fired up ILSpy and according to it, those methods are empty

    // Microsoft.SqlServer.Dts.Pipeline.ScriptComponent
    public virtual void PostExecute()
    {
    }
    
    // Microsoft.SqlServer.Dts.Pipeline.ScriptComponent
    public virtual void PreExecute()
    {
    }
    

    To refresh my memory on virtual (C# reference)

    The virtual keyword is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class. For example, this method can be overridden by any class that inherits it: