I have experienced some strange (to me at least) behavior when calling Session.Connect. It seems that if the Session.UpdateEndpoint event is registered with an empty event handler, my connect operation will fail with a StatusException with the message "No such host is known". A sample below:
Code: Select all
public partial class MainWindow : Window
{
private ApplicationInstance _application;
private Session _session;
public MainWindow()
{
InitializeComponent();
_application = new ApplicationInstance { AutoCreateCertificate = true };
_application.Start();
_session = new Session(_application);
_session.UseDnsNameAndPortFromDiscoveryUrl = true;
_session.UpdateEndpoint += SessionOnUpdateEndpoint; // If this line is commented, the connect works
}
private void SessionOnUpdateEndpoint(Session sender, UpdateEndpointEventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
_session.Connect(@"opc.tcp://172.16.0.1:48010", SecuritySelection.None, _session.DefaultRequestSettings);
}
}
In what situations should I register for this event, and what are the actions one should take?