Forum Discussion
OTS02
Cirrus
Mar 06, 2009set monitor state
I am trying to set a pool member monitor state to disabled. I think that I am very close with this code:
private void SetMonitorState(string pool, string memberaddr, long memberport)
{
string[] pool_names = new string[] { pool };
LocalLBPoolMemberMemberMonitorState[][] monitor_states;
monitor_states = new iControl.LocalLBPoolMemberMemberMonitorState[2][];
monitor_states[0] = new LocalLBPoolMemberMemberMonitorState[1];
monitor_states[0][0].member = new iControl.CommonIPPortDefinition();
monitor_states[0][0].member.address = memberaddr;
monitor_states[0][0].member.port = memberport;
monitor_states[0][0].monitor_state = CommonEnabledState.STATE_DISABLED;
m_interfaces.LocalLBPoolMember.set_monitor_state(pool_names, monitor_states);
}
I get a "Object reference not set to an instance of an object." error on the line -
monitor_states[0][0].member = new iControl.CommonIPPortDefinition();
I would be very grateful, if someone could point out my mistake.
2 Replies
- You are close. You haven't allocated a value for the monitor_states[ 0 ][ 0 ] value. This should work for you:
private void SetMonitorState(string pool, string memberaddr, long memberport) { string[] pool_names = new string[] { pool }; LocalLBPoolMemberMemberMonitorState[][] monitor_states; // Allocate a 2-d array monitor_states = new iControl.LocalLBPoolMemberMemberMonitorState[ 1 ][]; // Allocate the first dimensions value to a 1-d array of size 1 monitor_states[ 0 ] = new iControl.LocalLBPoolMemberMemberMonitorState[ 1 ]; // Allocate the value for the entry in the first element of the second dimension monitor_states[ 0 ][ 0 ] = new iControl.LocalLBPoolMemberMemberMonitorState(); // Allocate the IPPortDefinition monitor_states[ 0 ][ 0 ].member = new iControl.CommonIPPortDefinition(); monitor_states[ 0 ][ 0 ].member.address = memberaddr; monitor_states[ 0 ][ 0 ].member.port = memberport; monitor_states[ 0 ][ 0 ].monitor_state = CommonEnabledState.STATE_DISABLED; m_interfaces.LocalLBPoolMember.set_monitor_state(pool_names, monitor_states); }
- OTS02
Cirrus
Thanks again Joe!
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects