Method not found SetDataTypeProperties in custom S

2019-01-28 09:24发布

问题:

I'm trying to build a simple custom SSIS component which looks at a single input column and validates it, creating an output column of type bool depending on the value of each row.

I've successfully built an even simpler component that takes a value and transforms it: that doesn't require fiddling with the output columns. In this instance I need to take in a string and output a boolean and the component needs to know that it outputs a boolean so I can feed the value into a conditional split.

I'm struggling to add the output columns. Based on code samples from Microsoft, I have done this:

public override DTSValidationStatus Validate()
{
    IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

    IDTSOutputColumn100 outputcol = output.OutputColumnCollection.New();
    outputcol.Name = "IsValid";
    outputcol.SetDataTypeProperties(DataType.DT_BOOL, 0, 0, 0, 0);

    return DTSValidationStatus.VS_ISVALID;
}

And then I attempt to populate it during the ProcessInput step:

public override void ProcessInput(int inputID, PipelineBuffer buffer)
{
    while (buffer.NextRow())
    {
        string str = buffer.GetString(0);
        buffer.SetBoolean(0, IsValid(str)); // validation code not relevant
    }
}

When I try to use this component in the package, I get this error:

The component has detected potential metadata corruption during validation.
Error at Data Flow Task [Uppercase [24]]: System.MissingMethodException: Method not found: 'Void Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutputColumn100.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType, Int32, Int32, Int32, Int32)'.
   at EmailValidation.Uppercase.Validate()
   at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostValidate(IDTSManagedComponentWrapper100 wrapper)

Searching on this error message has yielded nothing of value.

In the original sample - and some other tutorials online - adding output columns is done by looping through the input column and adding an additional output for each. I have tried this and get the same error.

I have also tried moving the output column code from Validate to OnInputPathAttached which still yields the same error.

What am I doing wrong?

回答1:

On investigation this appears to be a bug in SQL Server Data Tools for Visual Studio 2015. I have built, deployed and used a custom component with customised output columns in an Integration Services package in Visual Studio 2013. However, the same tool deployed in a package in 2015 causes the error described.



回答2:

In case it's still relevant, I encountered a similar issue (With the ComponentMetaData property rather than SetDataTypeProperties), and the solution that worked for me was setting the Embed Interop Types property of the Microsoft.SqlServer.DTSPipelineWrap and Microsoft.SQLServer.DTSRuntimeWrap references to false.

I found this solution here. It's listed as a solution for getting an InvalidCastException, but it seems relevant for whenever you're referencing the DTSPipelineWrap or the DTSRuntimeWrap assemblies in custom components.