- Thank you received: 0
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.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- Browsing, Browse Dialogs and Controls
- daItemDialog causes System.NullReferenceException
daItemDialog causes System.NullReferenceException
Please Log in or Create an account to join the conversation.
The message box that pops out says that it is "first-chance exception". This means that is shows at the moment an exception has been just thrown. It does not mean that it was unhandled or that it propagate to your code. The Visual Debugger shows this message box because in your debug settings (Debug -> Exceptions"), you have checked "Thrown". This kind of setting gives you a chance to observe any exception at the moment it is being thrown. The calling code (it is actually Microsoft code) catches this exception and handles it, so if you uncheck "Thrown", the message box should disappear. Or, you can also press "Continue" in the message box. There also should be no such issue if you run the program outside the debugger.
Various libraries can contain code that internally throws exceptions and then handles them (it is not effective approach in terms of performance, but sometimes it is appropriate or the only way to do it). So, one has to be careful that when "Thrown" is checked in the debug options, not all reported exceptions are of any interest to you.
Kind regards,
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
The reason you cannot catch the exception is because it is happening on an internal thread, different from your thread that is invoking the dialog.
Kind regards
Please Log in or Create an account to join the conversation.
> System.Windows.Forms.dll!System.Windows.Forms.SendKeys.LoadSendMethodFromConfig() + 0x8d bytes
System.Windows.Forms.dll!System.Windows.Forms.SendKeys.Send(string keys, System.Windows.Forms.Control control, bool wait = true) + 0xf9 bytes
System.Windows.Forms.dll!System.Windows.Forms.SendKeys.SendWait(string keys) + 0x1e bytes
OpcLabs.BaseLibForms.dll!OpcLabs.BaseLib.Forms.Browsing.BrowseNodesForm.SendKeyAfterDelay(object thread) + 0x42 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x83 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj) + 0x4a bytes
Thanks again.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
NullRefException_bw.jpg
I also have a try/catch block around my code, but it doesn't seem to catch the exception. Below is the code I'm executing...
private void button10_Click (object sender, EventArgs e)
{
// BROWSE
try
{
Console.WriteLine ("mach name: {0}; server ProgID: {1}",
comboBox1.Text, comboBox2.Text);
Debug.Assert (comboBox1.Text != null);
Debug.Assert (comboBox2.Text != null);
daItemDialog1.ServerDescriptor.MachineName = LOCALHOST; // comboBox1.Text;
daItemDialog1.ServerDescriptor.ServerClass = comboBox2.Text;
if (daItemDialog1.ShowDialog () == DialogResult.OK)
{
//Debug.Assert (daItemDialog1.NodeElement != null);
//richTextBox1.Text += daItemDialog1.NodeElement.ItemId + Environment.NewLine;
}
}
catch (Exception ex)
{
MessageBox.Show (ex.Message);
}
}
I'm a seasoned programmer, but fairly new to C#; please don't hesitate to make suggestions that would add to my knowledge!
Thank you!
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
if (daItemDialog1.ShowDialog () == DialogResult.OK)
{
//Debug.Assert (daItemDialog1.NodeElement != null);
//richTextBox1.Text += daItemDialog1.NodeElement.ItemId + Environment.NewLine;
}
I have set daItemDialog1.ServerDescription's MachineName and ServiceClass to non-null values. If I "Cancel" in the dialog it exits cleanly. If I select an item (with a single click), within seconds an MVS error box indicates "A first chance exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll Additional information: Object reference not set to an instance of an object."
Any thoughts as to why this is happening? (Running VS 2008 on Windows Server 2003 Enterprise Edition, SP2.) Thanks!
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- Browsing, Browse Dialogs and Controls
- daItemDialog causes System.NullReferenceException