Resgrid.Console.exe dbupate throws unhandled exception
See original GitHub issueResgrid.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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top 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 >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 implemented your fix in https://github.com/Resgrid/Core/pull/21.
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.