private void button6_Click(object sender, EventArgs e) { // 获取本机已经注册的服务器地址 string endpointUrl = new Opc.Ua.Client.Controls.DiscoverServerDlg( ).ShowDialog(opcUaClient.AppConfig, null); // 获取其他服务器注册的地址,注意,需要该IP的安全策略配置正确 // string endpointUrl = new Opc.Ua.Client.Controls.DiscoverServerDlg( ).ShowDialog( opcUaClient.AppConfig, "192.168.0.100" ); if (!string.IsNullOrEmpty(endpointUrl)) { // 获取到的需要操作的服务器地址 } }
private void Server_DiscoverMI_Click(object sender, EventArgs e) { try { string endpointUrl = new Opc.Ua.Client.Controls.DiscoverServerDlg().ShowDialog(m_configuration, null); if (endpointUrl != null) { UrlCB.SelectedIndex = -1; UrlCB.Text = endpointUrl; } } catch (Exception exception) { MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }