I have an SSIS package in Visual Studio 2014, and I want to raise an error in a Script Component if any records traverse a particular path out of a 3rd party transformation. I WANT to do this in C# 2012, but the FireError method gives an error:
The best overloaded method match for 'Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100.FireError(int, string, string, string, int, out bool)' has some invalid arguments
When I try to do this:
bool fireAgain = false;
IDTSComponentMetaData100 myMetaData;
myMetaData = this.ComponentMetaData;
myMetaData.FireError(0, "Script Component", "Invalid Records", string.Empty, 0, ref fireAgain);
but if I change FireError to FireInformation, it compiles and works -- except of course I need an error raised, not an informative event.
Also, if I use Visual Basic instead of C# as so:
Dim pbFireAgain As Boolean = False
Dim myMetaData As IDTSComponentMetaData100
myMetaData = Me.ComponentMetaData
myMetaData.FireError(0, "Script Component", "Invalid Records", String.Empty, 0, pbFireAgain)
Which is, I mean, literally the same exact thing but in a different language, it works fine. VB also works with FireInformation.
Obviously I can solve my immediate problem by using VB, but can someone tell me WHY this is this way? It seems like a specific issue with C#. As evidence, we have this on MSDN: https://msdn.microsoft.com/en-us/library/ms136031.aspx
Where the Script Component version of FireError is the only of eight examples to not have C# and VB versions (the logging one is poorly formatted, but they're both there).
I'm wondering if there's a debugger configuration that threatens to run C# code in an odd way, as this stackoverflow question answered, but the error I get is at design time -- Visual Studio springs the earlier "invalid arguments" error before I compile, so it knows something is off.
Thoughts?
You may be confusing the similar but different syntax for firing error vs information events from Script Components (data flow task) versus Script Tasks (control flow). The intellisense for Component indicates that the parameter is pbCancel whereas the fireAgain corresponds to the Information Task's parameter.
Script Component
C# Script Component example
VB Component
There's no need to explicitly specify that a parameter is By Reference since that appears to be done in the definition versus the C# requirement to specify it also on invocation. ByRef vs ByVal Clarification
Script Task
C#
VB
Summary
ref
andout
keywords. They are not synonymsYou are passing it by
ref
, notout
, in your C#. I don't think VB.NET needs those keywords.