I am trying to load the binary contents of a file into ByteArrayContent
using the following powershell:
$arr = Get-Content $pathToFile -Encoding Byte -ReadCount 0
$binaryContent = New-Object System.Net.Http.ByteArrayContent($arr)
I receive the following error when the script is ran:
Cannot find an overload for "ByteArrayContent" and the argument count: "460"
I'm running this script on Windows 8.1, using Powershell 4.0.
Checking the documentation there are two overloads for ByteArrayContent
, I'm using the first so I ensured that I'm parsing a byte[]
array to the ctor.
In the end I used the other ctor and everything worked:
$binaryContent = New-Object System.Net.Http.ByteArrayContent($arr, 0, $arr.Length)
I checked the version of the System.Net.Http assembly I am using, by running the following command to see all the loaded assemblies:
[System.AppDomain]::CurrentDomain.GetAssemblies()
v4.0.30319 => C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0
In the MSDN documentation I can't see any other versions of the ByteArrayContent
, so any ideas on what describes this behaviour?