473,890 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application.Run (<ApplicationCo ntext>) Error 'Item has already been added. Key in dictionary: "- 1" key being added: "- 1"'


I have a Application, this throws after some time following exception:

Item has already been added. Key in dictionary: "- 1" key being added: "- 1"

I use Application.Run with ApplicationCont ext.

This error message comes from deeper levels must be thrown (mscorlib.dll?! )

I saw a similar problem. (see

For references, Tipps and solutions I would be grateful.

Ralf Gedrat

Here is a simple example of Code:


Public Class ClassMyApplicat ion
Inherits System.Windows. Forms.Applicati onContext
Private WithEvents PrivateForm1 As New Form
Private WithEvents PrivateForm2 As New Form
Private WithEvents PrivateForm3 As New Form
Private WithEvents PrivateFormN As New Form
Public Sub New()
Call PrivateForm1.Sh ow()
Call PrivateForm2.Sh ow()
Call PrivateForm3.Sh ow()
Call PrivateFormN.Sh ow()
PrivateForm1.Lo cation = New Point(0, 0)
PrivateForm2.Lo cation = New Point(32, 32)
PrivateForm3.Lo cation = New Point(64, 64)
PrivateFormN.Lo cation = New Point(96, 96)
End Sub
Private Sub PrivateFormX_Cl osing(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles PrivateForm1.Cl osing,
PrivateForm2.Cl osing, PrivateForm3.Cl osing, PrivateFormN.Cl osing
Call PublicClassMyAp plication.ExitT hread()
End Sub
Private Sub TuWasMitDerForm (ByVal sender As Object, ByVal e As
System.EventArg s) Handles PrivateForm1.Cl ick, PrivateForm2.Cl ick,
PrivateForm3.Cl ick, PrivateFormN.Cl ick
CType(sender, Form).Text = Now
End Sub
End Class
Module ModuleMyApplica tion
Public PublicClassMyAp plication As ClassMyApplicat ion
<STAThread()> Public Sub Main()
Dim ClApplicationLo aded As Boolean
PublicClassMyAp plication = New ClassMyApplicat ion
Call Application.Run (PublicClassMyA pplication)
Catch ex As Exception
Call MsgBox(ex.Messa ge)
End Try
End Sub
End Module

***END CODE***

Here is a listing from

Found the following interesting discussion in the Newsgroups:

Error after a few hours of DoEvents
by:Jeff Cooper

I have an app that often has no windows and uses a NotifyIcon. My Sub
has a loop:
Do Until gExit

Application.DoE vents()


When running the app in development, it works fine. But when running
exe, DoEvents() raises the following error after several hours:

An unhandled exception of type 'System.Argumen tException' occurred in
Additional information: Item has already been added. Key in
"-1" Key being added: "-1"

There's nothing in my app that should happen without human interaction
(clicking, double-clicking the notifyicon, etc). So I'm not sure
happening here. The program is basically just sitting there, waiting
something to happen. I left it running last night and found the error
morning, so it's not like I'm accidentaly clicking a window or icon
raising something. I can't find anything in various groups relating to
this. Anyone have any thoughts?



by:Armin Zingler

Replace the whole loop by


Otherwise you get 100% CPU usage. Instead of setting gExit, call
application.Exi tThread. If this doesn't fix the problem, find out the
line and post it here.

How to quote and why:

by:James Uren
I'm having the same problem - my loop's almost identical - help us


Nov 21 '05 #1
0 4223

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Kaveri | last post by:
Hi, I'm working with Data Sets and testing my application with multiple browser Instances. In the Application I'm merging diff datasets into a consolidated one and then displaying. This works fine for very small no of records.But if I increase the no of records I'm getting a Server Application unavailable Error. which on seeing the Application Event Log states that error occured due to insufficient RAM Memory. I'm already testing with...
by: MaxiWheat | last post by:
Hi, I am using a software that uses MS Word to create PDF files. When I try to run the sample code (ASP 3.0), I get an error on this statement : Set oWord = Server.CreateObject("Word.Application") That error says : The call to Server.CreateObject failed while checking permissions. Access is denied to this object.
by: Ken Cox [Microsoft MVP] | last post by:
MS has posted this here: http://www.asp.net/faq/ms03-32-issue.aspx Fix for: 'Server Application Unavailable' Error after Applying Security Update for IE ------------------------------------------------------------------------------- -
by: Kim NÝrby Andersen | last post by:
Hello there I am lost. i receive the output in the bottom, from a site that runs excellently on our development server, but dies on the customer. We have had a first version running at the customer, did some changes, recompiled, zipped and sent it back to them, but then it screwed up. As a part of the debugging process, the ASP.NET has been set to run as SYSTEM, and all folders described in...
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
by: alan | last post by:
I've try to deploy my application by using Setup Wizard. But after I build the setup application, it got a error said "unrecoverable error!". I don't know what's the problem. In order to the what problem is it, I open a new project and just use one form, use one text box and one button and try to deploy by setup wizard. Finally it also said "unrecoverable error!". What's wrong with it? It's just a simple application, why it got this...
by: Tom | last post by:
I have built a VS 2005 C++ application (ported from VC++ 2003). It's a WinForm app. It runs OK on the development system, but when I try to deploy it on any other system, all users gets an error box, "Application configuration Error. Try re-installing the application. (Deployed using an MSI setup project). I downloaded Dependency Walker, and it says that 2 DLL's are not found: DWMAPI.DLL, EFSADU.DLL
by: Wes Groleau | last post by:
I was doing update statements in SQL Server 2000. I have a table with over 16 million rows. It came from several hundred delimited text files, and two of the columns are file ID (int) and Line # (int) Structure is X12 (835). For those unfamiliar with that, each file has one to many BPR lines; each BPR line has zero to many CLP lines, each of those has zero to many
by: Cralis | last post by:
Hello! Started a new job as a novice c# developer. My line manager has asked our team to do a test on an application the company has already made. Basically, he wants a small tool that can control the app, remotly. Basically, the app needs to send a command to the app, and theapp will open certain screens. He mentioned the use of some sockets. The app will be in another city, so we need to connect to it over a WAN. I was thinking of...
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else:
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.