我試圖加載文件的二進制內容爲ByteArrayContent
使用以下的PowerShell:爲什麼PowerShell中找不到`ByteArrayContent`字節數組構造?
$arr = Get-Content $pathToFile -Encoding Byte -ReadCount 0
$binaryContent = New-Object System.Net.Http.ByteArrayContent($arr)
我收到以下錯誤,當劇本然:
Cannot find an overload for "ByteArrayContent" and the argument count: "460"
我跑這腳本在Windows 8.1上,使用Powershell 4.0。
檢查文檔有兩個重載ByteArrayContent
,我使用第一個,所以我確保我正在解析一個byte[]
數組到ctor。
最後,我用其他的構造函數和一切工作:
$binaryContent = New-Object System.Net.Http.ByteArrayContent($arr, 0, $arr.Length)
我檢查我使用的是System.Net.Http集的版本,運行以下命令來查看所有加載的程序集:
[System.AppDomain]::CurrentDomain.GetAssemblies()
v4.0.30319 => C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0
在MSDN文檔,我看不到ByteArrayContent
任何其他版本的,所以什麼描述這種行爲的任何想法?
相關:http://stackoverflow.com/questions/12870109/how-do-i-call-new-object-for-a-constructor-which-takes-a-single-array-parameter – 2014-12-05 09:55:55