title: SSIS Script task error "Exception has been thrown by the target of an invocation."
body: <p>I have the following script in SSIS using Pdfsharp library:</p>
  
  <hr>
  
  <pre><code>#Region "Imports"
  Imports System
  Imports System.Data
  Imports System.Math
  Imports PdfSharp.Pdf
  Imports PdfSharp.Pdf.IO
  Imports Microsoft.SqlServer.Dts.Runtime
  #End Region
  
      Public Sub Main()
          '
          ' Add your code here
          '
          Dim document As PdfDocument
          Dim doc_name As String
          doc_name = "C:\temp\Testfile.pdf"
  
          document = PdfReader.Open(doc_name)
  
  
          document.Info.Author = "TestTest"
  
          document.Save(doc_name)
  
          Dts.TaskResult = ScriptResults.Success
      End Sub
  </code></pre>
  
  <p>It's failing with an error "Exception has been thrown by the target of an invocation." on PdfReader.Open line. Steps executed: Pdfsharp library is placed in C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn folder and solution recognizes it. I have access to that file and can open it.  What else can cause this error in this super simple code? Would appreciate any advice.</p>