Page 1 of 1

Unhandled Exception adding Item to an Unknown(?) Dictionary

Posted: Sun Feb 09, 2014 9:47 am
by andis59
I have a script that creates an Named Pipe Server in it's own thread.
The Named Pipe Server is called from a client with commands which it executes in some of these commands(functions) I update a Tag.

Now I got an error, here is the relevant part of the logfile
2014-02-07 12:22:13,913 [13] FATAL Neo.ApplicationFramework.Common.Runtime.GlobalsBase [(null)] - Unhandled Exception causing shutdown.
System.ArgumentException: Item has already been added. Key in dictionary: 'Neo.ApplicationFramework.Generated.Screen1/Default' Key being added: 'Neo.ApplicationFramework.Generated.Screen1/Default'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.a2(Object A_0, Object A_1, String A_2)
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.at(IScreen A_0)
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.GetScreenObject(Type type, String instanceName)
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.GetScreenObject[T](String instanceName)
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.GetScreenObject[T]()
at Neo.ApplicationFramework.Generated.ScriptModule1.UpdateOrderNo(String msg) in c:\LaMine\Hmi IX files\LaMine_Mk2_119_ix200\ScriptModule1.Script.cs:line 332
at Neo.ApplicationFramework.Generated.ScriptModule1.StartOrder(String msg, String& response) in c:\LaMine\Hmi IX files\LaMine_Mk2_119_ix200\ScriptModule1.Script.cs:line 353
at Neo.ApplicationFramework.Generated.PipeServer.ThreadStartServer() in c:\LaMine\Hmi IX files\LaMine_Mk2_119_ix200\ScriptModule1.Script.cs:line 448
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


As I see it the error is that I (or someone) is trying to add an item to a dictionary but the Key already exists.
The dictionary seems to be: 'Neo.ApplicationFramework.Generated.Screen1/Default'

Where and what is this dictionary?

The code that is run in UpdateOrderNo(string msg) look like this:

Code: Select all

public void UpdateOrderNo(string msg)
        {
            OrderNo = msg;
            // Call to an external Assembly/Dll
            le.SetOrderNumber(OrderNo);

            Globals.Tags.OrderNo.Value = OrderNo;
            Globals.PopupLoad.Show();
			// here is line 332
            Globals.Screen1.Show();
        }
I don't know which line 332 is referencing to since it's pointing to a blank line!

Anyone that have an idea on what's wrong??

// Anders

Re: Unhandled Exception adding Item to an Unknown(?) Diction

Posted: Wed Feb 12, 2014 5:17 pm
by stuartm
You can open up this project in visual studio:

After a rebuild do the following:

.../temp/outputCF.csproj

look for the file:

ScriptModule1.Script.cs

Look at line 332

Re: Unhandled Exception adding Item to an Unknown(?) Diction

Posted: Fri Feb 14, 2014 8:23 am
by andis59
Ok, that good to know! Still pointed to an empty line...

Anyhow, I have found the problem! I have a textbox and an changed event and this event called the UpdateOrderNo(); and somehow the function Globals.PopupLoad.Show(); in UpdateOrderNo tiggered a change i the textbox which then called ...
So I guessing that after a while the dictionary got confused :lol:

I have now changed this and it works.

Strange though in Simulator mode is't affected by this. Here everything works as was??

// Anders