Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Browse machines - DCOM, ComputerBrowserDialog with threads

More
05 Jan 2012 13:38 #737 by support
S.,




I think I have found the reason: The shell function I am calling to show the dialog probably needs a message pump running on the thread. The message pump exists on UI threads, but not (by default) on a thread created with simple “new Thread()” call.


I have implemented a solution for this, so from the next build, it should work well from any thread.
I have also included the missing the documentation for ComputerBrowseDialog.

I am not, however, making this new build right now; but if you must have the fixes soon, let me know and I will make it.

Thanks again for your analysis!

Best regards,
Zbynek Zahradnik

From: S.
Sent: Monday, January 02, 2012 12:59 PM
To: Zbynek Zahradnik
Subject: ComputerBrowserDialog with threads

Hello Zbynek,

You might remember our discussion about the ComputerBrowserDialog last week. Today I got the thing working. But I have found a very strange thing about it which I think you should know.

In my application where I couldn’t get the dialog to display was due to I was running it in a separate thread. The QuickOPC v3 version I had run the dialog in a separate thread. I just switch the API and let the thread remain. Therefore the dialog with v5.12 didn’t appear.

You can actually test this very simple:

1) Create a Windows Forms application or WPF application
2) Add reference to OpcLabs.EasyOpcClassic, OpcLabs.EasyOpcClassicForms and System.Windows.Forms (WPF only)
3) Create this simple function:

private void Test()
{
OpcLabs.EasyOpc.DataAccess.Forms.ComputerBrowserDialog dialog = new OpcLabs.EasyOpc.DataAccess.Forms.ComputerBrowserDialog();
dialog.ShowDialog();
}

4) Enable the Form.Load method or Window.Loaded (WPF) and call the Test() method.
5) Run the application and the ComputerBrowserDialog window should popup.
6) Edit the .Load/.Loaded window with this code instead:

System.Threading.Thread thread = new System.Threading.Thread(Test);
thread.Start();

7) Run the application and no ComputerBrowserDialog window will appear.

I cannot explain why but I got it working with the same thread as my GUI.

/S.

From: Zbynek Zahradnik [This email address is being protected from spambots. You need JavaScript enabled to view it.]
Sent: den 29 december 2011 10:03
To: S.
Subject: RE: Browse machines - DCOM

S.,

[....]
here are first reactions:

ComputerBrowserDialog is the right one to get names of computers. In order to get list of servers on a particular computer, though, the right class is OpcServerDialog.

In the Concepts document, there is a chapter about this, called “OPC Common Dialogs”. I am including as copy of it below.
In the Reference documentation, these classes should be described as well: see e.g. www.opclabs.com/onlinedocs/QuickOpcClassic/5.12/Reference/Qu...f24-56bc-8ed3-062b33549a4d.htm .

BUT you have spotted a problem: The ComputerBrowserDialog does not appear in the Reference indeed – thanks, I will fix it in later version.

Your code to invoke the ComputerBrowserDialog is correct. There is similar example of this in the source code of the demo application, which is supplied with the product. Look in C# example, the example name is EasyOpcNetDemo.
So, I do not know why this does not show the dialog right now. This dialog is somewhat special in that it is not actually implemented by us – it just invokes a common Shell dialog for selecting computers, over which we have limited control. I have seen situations in which the dialog does appear, but hidden under the current window – isn’t that your case? (try Alt-Tabbing all windows, or other window manipulations). In some situations it may also take long time before it appears – this now also happens on my computer, so I will investigate later.

As to the last part of your email:
“Also, you should document somewhere for ComputerBrowserDialog class that reference to System.Windows.Form is neccecery to view inherited properties and methods from System.Windows.Forms.CommonDialog. Or else .ShowDialog() method is not accecible.”

We may make a note of it, but that is a general behavior of a particular tool (Visual Studio), and what’s more important, similar things probably apply to many other places in the software, where one assembly inherits from a type located in another assembly. My concern is that we can never do it fully right, and if we do, the documentation will become spoiled by too many comments like this. Also, if you set up a Windows Forms project in the usual way, the reference to System.Windows.Forms will be there already anyway.

Best regards,
Zbynek

OPC Common Dialogs
QuickOPC.NET contains a set of Windows Forms dialog boxes for performing common OPC-related tasks such as selecting an OPC server or OPC item.
The dialog objects are all derived from System.Windows.Forms.CommonDialog, providing consistent and well-known programming interface to use.
Computer Browser Dialog
OPC servers are usually deployed on the network, and accessed via DCOM. In order to let the user select the remote computer where the OPC server resides, you can use the ComputerBrowseDialog object.
Call the ShowDialog method, and if the result is equal to DialogResult.OK, the user has selected the computer, and its name can be retrieved from the SelectedName property.
OPC Server Dialog
If you do not know upfront which OPC server to connect to, and do not have this information from any other source, your application will need to allow the user select the OPC server(s) to work with. The OPC Server Dialog allows the user to select the OPC server interactively from the list of OPC Data Access servers installed on a particular machine.
Set the MachineName property to the name of the computer that is to be browsed, and call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC Data Access server, and information about it can be retrieved from the SelectedServer property.
OPC-DA Item Dialog
The OPC-DA Item Dialog allows the user to interactively select the OPC item residing in a specific OPC server.
Use the Server property to specify the OPC Data Access server whose items are to be browsed, and call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC item, and information about it can be retrieved from the SelectedNode property.
OPC-DA Property Dialog
The OPC-DA Property Dialog allows the user to interactively select the OPC property on a specific OPC item.
Use the Server property to specify the OPC Data Access server whose items are to be browsed, set the ItemId property to the OPC Item Id needed, and then call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC property, and information about it can be retrieved from the SelectedProperty property.

From: S.
Sent: Thursday, December 29, 2011 9:32 AM
To: Zbynek Zahradnik
Subject: Browse machines - DCOM

Hello again!

I’m trying to find the code in QuickOPC v5.12 how to browse machines and see what OPC-servers are installed on remote machines.
In the reference I cannot find anything about this. I was able to find the ComputerBrowserDialog class which I guess does this. But when I run the .ShowDialog() method I’m not promted with a dialog box. This is my code:

ComputerBrowserDialog dialog = new ComputerBrowserDialog();
dialog.ShowDialog();

Is this wrong approatch? Or do I miss some parameters?

Also, you should document somewhere for ComputerBrowserDialog class that reference to System.Windows.Form is neccecery to view inherited properties and methods from System.Windows.Forms.CommonDialog. Or else .ShowDialog() method is not accecible.

Best regards!

S.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.068 seconds