Is the event handler limited under PowerShell v2 ?

BatchMan

New Member
Hi,
this script do not work (BindingList.AddingNew Event) :
Code:
#The PSMemberSet class has not a default constructor 
$listOfParts = new-object System.ComponentModel.BindingList[System.Management.Automation.PSMemberSet]
 
$listOfParts.AllowNew = $true
$listOfParts.AllowRemove = $True
$listOfParts.AllowEdit = $True;
# Raise ListChanged events when new parts are added.
$listOfParts.RaiseListChangedEvents = $true
 
Register-ObjectEvent $listOfParts AddingNew "AddingNew" -Action {
 Write-Warning "args count"; 
 Write-host $event.SourceArgs.Count
 $EventArgs|select * |write-host 
 $obj=New-object System.Management.Automation.PSMemberSet "Test1"
 #$EventArgs.NewObject=$Obj
 $Event.SourceArgs[1].NewObject=$Obj
}
 
Register-ObjectEvent $listOfParts ListChanged "ListChanged" -Action {
 Write-WarnIng "ListChanged"
 $EventArgs|select * |write-host
 Write-Host $EventArgs.ListChangedType.ToString()
}
 
$Newpart=$listOfParts.Add((New-object System.Management.Automation.PSMemberSet "Test0"))
 
$Newpart=$listOfParts.AddNew()
#exception
# [URL="http://msdn.microsoft.com/en-us/library/ms132687(v=VS.80).aspx"]BindingList.AddNew Method (System.ComponentModel)[/URL]
$listOfParts.EndNew($listOfParts.Count)
It is a limit or a bug ?
 

My Computer

Top