Photo_G_84660
Mar 21, 2007Nimbostratus
"Unable to cast object of type 'System.Object[]' to type 'iControl.LocalLBPoolMemberMemberSessionState[][]'."
Hi,
I'm trying to code a method to disable pool members in VB .NET (using the new iControl.dll, THANKS JOE!!!), and it appears (in the debugger) to properly present the [pool_names] string and session_states info [CommonIPPortDefinition] and [session_state] to the set_session_enabled_state method, but I'm getting this error:
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'System.Object[]' to type 'iControl.LocalLBPoolMemberMemberSessionState[][]'."
When the sub below gets to set_session_enabled_state(pool_names, session_states), the error above indicates that set_session_enabled_state will not accept an object for the "list of lists" that makes up the MemberSessionState[][] type.
However, if I try to force force it to an array i.e.."Dim session_states() As Array = {member_list(0)(index), (status)}", the array wont accept CommonIPPortDefinition (Unable to cast object of type 'iControl.CommonIPPortDefinition' to type 'System.Array'). So, it appears that I'm missing something about the MemberSessionState[][] type.
Any hints or suggestions would be greatly appreciated. Thanks in advance!
Public Sub lbxNodes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles lbxNodes.SelectedIndexChanged
Dim sHostname As String = txt_hostname.Text
Dim sUsername As String = txt_username.Text
Dim sPassword As String = txt_password.Text
Dim m_interfaces As iControl.Interfaces = New iControl.Interfaces
m_interfaces.initialize(sHostname, sUsername, sPassword)
Dim pool_names() As String = {"pool1"}
Dim index As Integer = lbxNodes.SelectedIndex
Dim checked As Boolean = lbxNodes.GetItemChecked(index)
Dim member_list()
member_list = m_interfaces.LocalLBPool.get_member(pool_names)
Dim status(0) As iControl.CommonEnabledState
If checked Then
status(0) = iControl.CommonEnabledState.STATE_ENABLED
Else
status(0) = iControl.CommonEnabledState.STATE_DISABLED
End If
Dim session_states() = {member_list(0)(index), status}
m_interfaces.LocalLBPoolMember.set_session_enabled_state(pool_names, session_states)
End Sub
Scott H.