Unhandled Exception adding Item to an Unknown(?) Dictionary

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
andis59
Posts: 13
Joined: Mon Apr 08, 2013 11:50 am

Unhandled Exception adding Item to an Unknown(?) Dictionary

Post 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

stuartm
Posts: 61
Joined: Thu Jun 06, 2013 9:21 am

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

Post 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

andis59
Posts: 13
Joined: Mon Apr 08, 2013 11:50 am

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

Post 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

Post Reply