Q:

How to deal with reference not found when trying to Add-Type in PowerShell, when the same dll loads fine in Visual Studio?

I am trying to reference the IBM.Data.DB2 and IBM.Data.Informix libraries from PowerShell.
I have some Visual Studio test code in which I simply added references to those dlls and started coding, everything went fine.
When attempting to add the same references in PowerShell I try the following:
try{
$DataType4 = Add-Type -Path "C:\Program Files\IBM\SQLLIB\BIN\netf40\IBM.Data.DB2.dll"
}
catch
{
$_.Exception | Format-List * -force
}

When trying to run this I get an extended error list which complains that Microsoft.ReportingServices isn't found (I think it isn't installed on this machine anyway; I've printed out my GAC and it doesn't appear there, though there are many references to Microsoft.ReportViewer; the successful Visual Studio project doesn't include Microsoft.ReportingServices in its references). From the look of things, LoaderException contains this information multiple times so I've only included one copy:
Types        : {IBM.Data.DB2.CS_FitHighPrecisionType, IBM.Data.DB2.LLIST, IBM.Data.DB2.LISTLOCK, IBM.Data.DB2.ADP...}
LoaderExceptions : {System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces, Version=10.0.0.0, Culture=neutral, 
               PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
               File name: 'Microsoft.ReportingServices.Interfaces, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

               WRN: Assembly binding logging is turned OFF.
               To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
               Note: There is some performance penalty associated with assembly bind failure logging.
StackTrace   :    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
                  at System.Reflection.Assembly.GetTypes()
                  at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
                  at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
                  at System.Management.Automation.CommandProcessorBase.Complete()

Can anyone explain why this seems to run fine in Visual Studio, but not in PowerShell? Am I retrieving the exception correctly? Is there some way around the missing Microsoft component, seeing as Visual Studio copes fine without it?
I feel like I'm doing something obviously wrong and heading off tilting at windmills, but I can't seem to find any other mentions of this issue.
EDIT: This is a screenshot of my tiny test project along with its references. It just fetches a table of data and dumps it into a DataGridView, but it shows the minimal amount of coding required to hook up a connection using these drivers.

A:

Following a weekend reboot, I've revised my answer:
It turns out that the exceptions thrown during the load process are non-fatal, so catching them and ignoring them works well enough for test code.
If the Add-Type fails in a more serious manner, I've got another try-catch around the entire execution block, and actually trying to access an Informix object on a "real" load failure throws an exception that's caught there.
Test code included for the benefit of any future searchers:
try{
$DataType7 = Add-Type -Path "C:\Program Files\IBM\SQLLIB\BIN\netf40\IBM.Data.Informix.dll"
}
catch
{
    #Throw a horrendous mass of exceptions, which we ignore, but output.
    $_.Exception | Format-List * -force
}

$ifxCStr = New-Object -TypeName IBM.Data.Informix.IfxConnectionStringBuilder
$ifxCStr.Server = "x"
$ifxCStr.Database = "x"
$ifxCStr.UserID = "x"
$ifxCStr.Password = "x"

$ifxConn = New-Object -TypeName IBM.Data.Informix.IfxConnection($ifxCStr.ConnectionString)
$ifxConn.Open()

$ifxCommand = $ifxConn.CreateCommand()
$ifxCommand.CommandText = "SELECT FIRST 100 * FROM tbl_x"

$ifxReader = $ifxCommand.ExecuteReader()

$ifxTable = New-Object System.Data.DataTable
$ifxTable.Load($ifxReader)
$ifxTable | Out-GridView

$ifxConn.Close()

