"The given key was not present in the dictionary" error
See original GitHub issueHI there,
I would like your help please. I’ve reported this issue at codeplex but I’ve realised I should have raised it here. Apologises.
I’ve created an IVR script on a webserver. It keeps failing randomly. To find out the issue, I wrote a CurrentDomain_UnhandledException. It prints out a message and the source of the error.
It gave this error.
The given key was not present in the dictionary.
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at AsterNET.FastAGI.AGIConnectionHandler.Run() in e:\Projects\Codeplex\AsterNET\Asterisk.2013\Asterisk.NET\FastAGI\AGIConnectionHandler.cs:line 103
at AsterNET.Util.ThreadTask.Run() in e:\Projects\Codeplex\AsterNET\Asterisk.2013\Asterisk.NET\Util\ThreadTask.cs:line 36
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
This is how I configured the agiServer component before starting it.
int PortNumber = ToolboxHelper.getSettingByNameAsInt("PortNumber");
AsteriskFastAGI agiServer=new AsteriskFastAGI
{
MappingStrategy = new GeneralMappingStrategy(
new List<ScriptMapping>()
{
new ScriptMapping()
{
ScriptName = "callmonitor", // script name - passed by the Asterisk server
ScriptClass = "AsteriskAGI.CallMonitorAGI" // code to run for this script
}
})
};
agiServer.BindPort = PortNumber;
try
{
agiServer.Start(); // Start the service. This runs synchronously - ctrl+c to exit
}
catch (Exception ex)
{
}
This error is occuring in the AsterNET code.
What’s happening in AGIConnectionHandler.cs at line 103? What key is it expecting? This happens randomly, perhaps also when a call has connected with my script.
Am I missing something in my setup?
Issue Analytics
- State:
- Created 9 years ago
- Comments:10
Top Results From Across the Web
The given key was not present in the dictionary. Which key?
This exception is thrown when you try to index to something that isn't there, for example: Dictionary<String, String> test = new ...
Read more >The given Key was not present in the dictionary
Symptoms. Consider the following scenario: · Cause. There is a faulty registry item in the XML file that is associated with the Group...
Read more >Solved: The given key was not present in the dictionary
Solved: Hello, I am having a refresh problem and I need help, Currently, I am using Power BI Desktop (January 2021), after applying...
Read more >[Solved] The given key was not present in the dictionary
Solution 1 Hi, Actually this exception occur when you are accessing Dictionary for Incorrect value. Here i have created one code snippet for ......
Read more >The given key was not present in the dictionary.
Generally 'The given key was not present in the dictionary' implies the VBO has no 'awareness' of the Excel file. The VBO keeps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve downloaded the source and made some changes to find the root of the issue. Apologises for the long post.
In AGIConnectionHandler.cs, around lines 93, where it throws an exception. I commented out the “throw ex” and got it to write the error message.
I found where the error was occuring.
I looked inside AGIRequest.cs for line 343, GeneralMappingStrategy.cs for line 132 and AGIConnectionHandler.cs for line 64.
AGIRequest.cs
GeneralMappingStrategy.cs
AGIConnectioHandler.cs
So what happened, it was trying to find the script from the Dictionary (mapAssemblies) with the “network_script” variable/name so an instance of the script can be created and executed.
What is “network_script”? Is this something I need to declare in my AGIServer setup?
I looked at examples in https://asternetsamples.codeplex.com/ and I don’t see anything referring to “network_script”, except I didn’t use the Answer(); or HangUp(); in my script. Are they required? I was able to execute the script without those. The random hanging still occurs. Example
Hi skrusty,
It’s written as a console application and it’s installed on a server. It’s a console applicaiton with framework set to 4.5.
This happens randomly. Is there any more infornation you would like?