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.

daItemDialog causes System.NullReferenceException

More
14 Jan 2013 16:31 #1168 by kasssa
Thank you for identifying my problem. I 'inherited' my VS2008 environment and did not realize the level of customization that is available. Your assistance is very much appreciated!

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

More
12 Jan 2013 09:28 #1165 by support
As it turns out, this is not a bug. I should have realized this earlier:
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.

More
11 Jan 2013 19:38 #1163 by kasssa
Thank you - I appreciate the update and the info.

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

More
11 Jan 2013 19:30 #1162 by support
Thank you. I have forwarded this issue to the programmer who worked on this part.
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.

More
11 Jan 2013 19:20 #1160 by kasssa
Thanks for the directions! Here is the Call Stack:
> 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.

More
11 Jan 2013 19:05 #1158 by support
When you press "Break", it gets you to the VS debugger, and there is a call stack window (if it is not visible, it can be shown by a menu command under Debug). It is possible to select all or parts of the call stack, and Copy it and then Paste somewhere.

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

More
11 Jan 2013 18:47 #1156 by kasssa
I'm just getting a Windows Visual Studio popup error message (below) - I don't see a call stack anywhere. Is there a way I can force one?
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.

More
11 Jan 2013 18:22 #1153 by support
Can you post a call stack of the exception please?

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

More
11 Jan 2013 16:06 #1150 by kasssa
When I execute the following code, a System.NullReferenceException is thrown -

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.

Moderators: support
Time to create page: 0.058 seconds