![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Passing array to .Net command: discrete parameters Hi- I was trying to instantiate some .Net objects from PowerShell, and I am confused about why this happens when I pass an array to the constructor: PS [Scripts] > $bytes=@([System.Text.Encoding]::UTF8.GetBytes("Hello There")) PS [Scripts] > new-object System.IO.MemoryStream($bytes) New-Object : Cannot find an overload for ".ctor" and the argument count: "11". At line:1 char:11 + new-object <<<< System.IO.MemoryStream($bytes) I see that this will work if I do this: PS [Scripts] > new-object System.IO.MemoryStream(,$bytes) However, I don't understand why my byte array of length 11 is getting passed as 11 parameters instead of as an array. Does anyone know why this happens? Is this the correct way to do this? Thanks! -Mike |
| | #2 (permalink) |
| Guest | RE: Passing array to .Net command: discrete parameters Hi- Sorry for the multiple posts. This worthless "Communities" forum site gave me errors when I clicked "post". -Mike "Mike Bridge" wrote: > Hi- > > I was trying to instantiate some .Net objects from PowerShell, and I am > confused about why this happens when I pass an array to the constructor: > > PS [Scripts] > $bytes=@([System.Text.Encoding]::UTF8.GetBytes("Hello > There")) > PS [Scripts] > new-object System.IO.MemoryStream($bytes) > New-Object : Cannot find an overload for ".ctor" and the argument count: "11". > At line:1 char:11 > + new-object <<<< System.IO.MemoryStream($bytes) > > I see that this will work if I do this: > > PS [Scripts] > new-object System.IO.MemoryStream(,$bytes) > > However, I don't understand why my byte array of length 11 is getting passed > as 11 parameters instead of as an array. Does anyone know why this happens? > Is this the correct way to do this? > > Thanks! > > -Mike > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing parameters to a cmdlet in a variable | Alastair Smith | PowerShell | 1 | 02-08-2008 06:29 AM |
| passing [switch] parameters | Jeff | PowerShell | 4 | 07-28-2007 09:17 AM |
| Passing parameters to a PS script | Dan | PowerShell | 9 | 07-17-2007 05:05 PM |
| passing parameters to script (ps1) | IT Staff | PowerShell | 1 | 10-19-2006 09:43 AM |
| Invoke-Item and passing command line parameters | =?Utf-8?B?cm9ib3Q=?= | PowerShell | 5 | 07-17-2006 08:48 PM |