question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resgrid.Console.exe dbupate throws unhandled exception

See original GitHub issue

Resgrid.Console.exe dbupate throws unhandled exception:

Unhandled exception. System.Configuration.ConfigurationErrorsException: The entry 'ResgridContext' has already been added.
   at System.Configuration.ConfigurationElementCollection.BaseAdd(ConfigurationElement element, Boolean throwIfExists, Boolean ignoreLocks)
   at System.Configuration.ConfigurationElementCollection.BaseAdd(ConfigurationElement element, Boolean throwIfExists)
   at System.Configuration.ConfigurationElementCollection.BaseAdd(ConfigurationElement element)
   at System.Configuration.ConnectionStringSettingsCollection.Add(ConnectionStringSettings settings)
   at Resgrid.Console.Program.SetConnectionString() in C:\ResGrid.Core\Tools\Resgrid.Console\Program.cs:line 87
   at Resgrid.Console.Program.Prime() in C:\ResGrid.Core\Tools\Resgrid.Console\Program.cs:line 42
   at Resgrid.Console.Program.Main(String[] args) in C:\ResGrid.Core\Tools\Resgrid.Console\Program.cs:line 27

I believe codes in line #86 and #87 can be removed as “ResgridContext” already exists after line #71 loaded AppOptions:ConfigPath successufully.

bool configResult = ConfigProcessor.LoadAndProcessConfig(Configuration["AppOptions:ConfigPath"]);

Or check the connection key before adding it to settings collection as below.

if (!configResult)
   settings.Add(new System.Configuration.ConnectionStringSettings("ResgridContext", Configuration["ConnectionStrings:ResgridContext"]));
else
{
   if (settings["ResgridContext"] == null)
   {
	settings.Add(new ConnectionStringSettings("ResgridContext", DataConfig.ConnectionString));
   }
}

Please correct me if I misunderstood something.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ucswiftcommented, Feb 15, 2021

I implemented your fix in https://github.com/Resgrid/Core/pull/21.

1reaction
ucswiftcommented, Feb 12, 2021

Ive added your suggested fix and pushed it up. https://github.com/Resgrid/Core/pull/20/files#diff-7d4c97ef391c3330c175ddf7077c0646e3d77994ea8be2c54de0bbc36fb94e1d I’ll be working on testing everything out this weekend to try and get the new release pushed out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resgrid.Console.exe dbupate -> error · Issue #2
C:\ResGrid\Tools>Resgrid.Console.exe dbupdate Resgrid Console Starting the Resgrid Database Update Process Please Wait... There was an error ...
Read more >
c# - How to catching Unhandled Exceptions in Console ...
Register a global exception handler in your main method like this: //Add handler to handle the exception raised by additional threads ...
Read more >
Unhandled exception when launching the console
ConfigurationManagement has stopped working error that occurs when you try to launch the System Center 2012 Configuration Manager console.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found