title: Receiving "index was was outside the bounds of an array" error in SSIS script component
body: <p>I have an SSIS package that is now failing with an error of "index was outside the bounds of an array." It is occuring in the script component task, but I can't see any further information in the log about what line it failed. Here is the text to my Script Component, can anyone see anything wrong with this? I haven't change anything in the package and it just started failing all of a sudden. </p>
  
  <pre><code>Imports System
  Imports System.Data
  Imports System.Math
  Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
  Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
  
  &lt;Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute&gt; _
  &lt;CLSCompliant(False)&gt; _
  Public Class ScriptMain
      Inherits UserComponent
  
  
      ' Wrapper for web service
  
      'Private CurrencyInfo As RetrieveExchangeRatesOutputMessageContract
  
      ' wrapper for Response from web service
  
      Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
  
          Try
              Dim ws As New CurrencyExchangeWS.CurrencyExchangeWS
              Dim inContract As New CurrencyExchangeWS.ExchangeRateInputDataContract
              Dim msg As New CurrencyExchangeWS.RetrieveExchangeRatesInputMessageContract
              Dim inContracts(1) As CurrencyExchangeWS.ExchangeRateInputDataContract
              'Dim dt As Date = Now
              'dt = dt.AddDays(-1)
  
              inContract.RequestAsOfDate = Now
              'inContract.RequestAsOfDate = "2011-07-18"
  
              ' IMPORTANT: You need to specify SourceCurrencyIdSpecified and TargetCurrencyIdSpecified or the service will assume these values are null.
              inContract.SourceCurrencyIdSpecified = True
              inContract.SourceCurrencyId = Row.CurrencyTypeId
  
              inContract.TargetCurrencyIdSpecified = True
              inContract.TargetCurrencyId = 47
  
              inContracts(0) = inContract
  
              msg.ExchangeRateInputCollection = inContracts
  
              ws.Credentials = System.Net.CredentialCache.DefaultCredentials
  
              Dim outMsg As CurrencyExchangeWS.RetrieveExchangeRatesOutputMessageContract = ws.RetrieveExchangeRates(msg)
  
              'Dim rate =outMsg.ExchangeRateInfoCollection(0).Rate
              Dim rate As Decimal = outMsg.ExchangeRateInfoCollection(0).Rate
  
              'Dim edate = outMsg.ExchangeRateInfoCollection(0).RequestAsOfDate
  
              Dim edate = outMsg.ExchangeRateInfoCollection(0).RateAsOfDate
  
              'Dim edate As DateTime
              'edate = outMsg.ExchangeRateInfoCollection(0).RateAsOfDate
  
  
              Row.date = edate
              Row.rate = Convert.ToDecimal(1.0 / rate)
  
              'Dim currency = outMsg.ExchangeRateInfoCollection(0).TargetCurrencyId
  
  
          Catch ex As Exception
  
              ComponentMetaData.FireError(1, ComponentMetaData.Name, ex.Message, String.Empty, 0, True)
  
          End Try
  
      End Sub
      Public Overrides Sub PreExecute()
          MyBase.PreExecute()
          '
          ' Add your code here for preprocessing or remove if not needed
          ''
      End Sub
  
      Public Overrides Sub PostExecute()
          MyBase.PostExecute()
          '
          ' Add your code here for postprocessing or remove if not needed
          ' You can set read/write variables here, for example:
          ' Me.Variables.MyIntVar = 100
          ''
      End Sub
  
      'Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
      '
      ' Add your code here
      '
      'End Sub
  
  End Class
  </code></pre>