Я получаю следующую ошибку в строке, помеченной «<<<» </p>
Method not found: 'Void System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<TKey>.Add(!0)'.
Вот код.
Обратите внимание, что uiControl содержит ссылку на элемент управления пользовательского интерфейса, а eventHandler не является ничем.
Public Function AddControlChangedEventHandler(ByVal uiControl As Control, _
ByVal eventName As String) As Boolean
'determine which value changed event handler this control accepts...
Dim eventHandler As EventInfo = GetControlValueChangedEventHandler(uiControl, eventName)
Dim eventSubscribed As Boolean = eventHandler IsNot Nothing
'if I found it
If eventSubscribed Then
Try
'...subscribe to it
SubscribeToChangedEvent(uiControl, eventHandler) '<<<<<<
Catch ex As Exception
'uh oh, control doesn't support
'this event name
eventSubscribed = False
End Try
End If
Return eventSubscribed
End Function
End Sub
Private Sub SubscribeToChangedEvent(ByVal uiControl As Control, ByVal eventHandler As EventInfo)
'details removed
End Sub