AdvancedHMI Software

General Category => Support Questions => Topic started by: AabeckControls on June 25, 2015, 12:04:16 PM

Title: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 12:04:16 PM
I can add a new page, put a FromChange button on the main screen & use it once. If I add another page & a FormChange for that I can go to that page, but if I try to go to the earlier accessable page I get a KeyNotFoundException error with the detail "The given key was not present in the dictionary".

If I add another page I can access the new page but both previous pages show the error. I do Build (&/or Rebuild tried too) after adding a new page, compared the properties of the working button with the non-working ones, insured that the FormToOpen is the correct page (& all 3 pages show up to select - so they're there)

Is there something I'm missing here or not doing right?
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 12:32:46 PM
This must be related to something else because the FormChangeButton does not access any dictionaries using keys.

Try using regular buttons and code like this:

- Add a Button from the All Windows Forms group in the Toolbox
- Double Click the button to get back to the code
- Add this code:

Form2.Show
Me.Hide


Change Form2 to the name of the form you want to open with the button.

See if you still get the error.
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 12:55:44 PM
Archie,

Tried that for pages 2 & 3 & constantly get same error for the pages that come up when I enter the code in the ViewCode.

BasicButton1_Click = Page2.Show
                                Me.hide

BasicButton2_Click = Page3.Show
                                Me.hide
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 12:57:46 PM
What version of AdvancedHMI and what driver are you using?
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 02:13:56 PM
AdvancedHMI Beta v398g
AB DF1Com1 driver (that all the PB's, pilot lights & meters work OK with)
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 02:25:32 PM
Archie,

When the error appears, the following code shows up highlighted (consistently the same section highlighted) but otherwise the DF1 driver works OK.
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 02:48:08 PM
I have been able to reproduce this with the DF1Com driver. I will work on this and get back to you with a fix.
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 02:57:48 PM
It looks like the DF1Com.vb needs 3 modifications:

- Edit AdvancedHMIDrivers\AllenBradley\Df1Com.vb
- Go to line 217 and change to this:

            If MyDLLInstance > 0 AndAlso (DLL IsNot Nothing) AndAlso (DLL.Count > MyDLLInstance) AndAlso DLL(MyDLLInstance) IsNot Nothing Then

- Go to line 242 and change to this:

            If MyDLLInstance > 0 AndAlso DLL.Count > 0 AndAlso DLL(MyDLLInstance) IsNot Nothing Then   'AndAlso Not DLL(MyDLLInstance).IsPortOpen Then

- The all the way near the bottom to line 430:

        If MyDLLInstance > 0 AndAlso DLL IsNot Nothing AndAlso  DLL.Count >= MyDLLInstance AndAlso DLL(MyDLLInstance) IsNot Nothing Then
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 04:06:41 PM
Pasted the 3 lines, but when I Build I get the following 3 errors about Line 243, tried adding parenthesis where i thought they might go, but then got Syntax Error.
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 04:17:22 PM
On line 242, the last part of the expression was commented out. Did you possibly remove that ' for the comment? This is the code at line 242 without the commented part:

 If MyDLLInstance > 0 AndAlso DLL.Count > 0 AndAlso DLL(MyDLLInstance) IsNot Nothing Then
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 05:09:16 PM
The comment is still commented out (')
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 05:31:33 PM
Some where it is picking up IsPortOpen, but the only place that appeared was in the commented out code. Do you see that any place else?
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 25, 2015, 05:35:51 PM
I posted a patch for the DF1Com:

https://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/Patches/

- Download and extract the file
- With AdvancedHMI open in Visual Studio, In Solution Explorer right click the folder AdvancedHMIDriver\AllenBradley then select Add->Existing Item
- Browse to the file that was downloaded and extracted
- It will ask if you want to overwrite the file, select Yes
- Rebuild the Solution
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 25, 2015, 06:35:00 PM
Downloaded it to my flash drive, will try it tomorrow 1st thing when I get back to work.

Thanks.
Title: Re: Form Change Causes KeyNotFoundException
Post by: AabeckControls on June 26, 2015, 12:34:09 PM
Archie,

Been a hectic day here & I just got around to this project & the new driver works OK.

Also, I saw the thread going on now about the MfgControl.AdvancedHMI.Drivers so I downloaded & installed that too.

Thank you.
Title: Re: Form Change Causes KeyNotFoundException
Post by: Archie on June 26, 2015, 12:59:44 PM
Sounds good. Thanks for the update and let me know if you find any other issues.

Less than 6 months ago the drivers for the SLC/Micro family was almost completely rewritten, so a new bug is still popping up here and there.