0

I get this error:

Failure:

System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section ServiceSettings/TycheConnectionString. (C:\KR_workspace\Alpha\Tyche\Applications\KPlusSynchronizer\KPlusSynchronizer\KPlusSynchronizerConsole\bin\Debug\KPlusSynchronizerConsole.vshost.exe.config line 17)
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   --- End of inner exception stack trace ---
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
   at System.Diagnostics.TraceSource.Initialize()
   at System.Diagnostics.TraceSource.get_Switch()
   at System.Transactions.Diagnostics.DiagnosticTrace..cctor()
   --- End of inner exception stack trace ---
   at System.Transactions.Transaction.get_Current()
   at System.Data.Common.ADP.IsSysTxEqualSysEsTransaction()
   at System.Data.Common.ADP.NeedManualEnlistment()
   at System.Data.Odbc.OdbcConnection.Open()
   at KPlusSynchronizer.Kplus.GetDataFromKplus(String kplusConnection, String sp) in c:\KR_workspace\Alpha\Tyche\Applications\KPlusSynchronizer\KPlusSynchronizer\KPlusSynchronizer\KPlus\Kplus.cs:line 24
   at KPlusSynchronizer.Kplus..ctor(String kplusConnection, String sp) in c:\KR_workspace\Alpha\Tyche\Applications\KPlusSynchronizer\KPlusSynchronizer\KPlusSynchronizer\KPlus\Kplus.cs:line 16
   at KPlusSynchronizer.Synchronizer.Synchronize(String tycheTable, String tycheSp, String kplusSp) in c:\KR_workspace\Alpha\Tyche\Applications\KPlusSynchronizer\KPlusSynchronizer\KPlusSynchronizer\KPlusSynchronizer.cs:line 34:

when I'm running my application. This is my app config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="ServiceSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
  <section name="KPlusSynchronizerConsole.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="TablesToSynchronize" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
  <section name="KPlusSynchronizerConsole.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>


<ServiceSettings>
<TycheConnectionString value="Data Source=xxxxx;Initial Catalog=xxxxxx;Integrated Security=True" />
<KplusConnectionString value="Driver={Adaptive Server Enterprise};UID=xxxxx;PWD=xxxxx;Database=xxxxxx;Server=xxxxx;Port=4130;" />
<LogFiles value="true" />
</ServiceSettings>

<TablesToSynchronize>
<Table name="Table1" tycheSp="xxxxx" kplusSp="xxxx"/>
<Table name="Table2" tycheSp="xxxxx" kplusSp="xxxx"/>
<Table name="Table3" tycheSp="xxxxx" kplusSp="xxxx"/>
</TablesToSynchronize>

</configuration>

So the error is thrown when I'm opening connection to a DB using the connectionstring. I would like some help how to set this up. Do I need both configSections? Is this even possible?

I would like to use this kind om format instead of appSettings

MrProgram
  • 5,044
  • 13
  • 58
  • 98

1 Answers1

0

Try

<ServiceSettings>
  <KPlusSynchronizerConsole.Properties.Settings>
    <TycheConnectionString value="Data Source=xxxxx;Initial Catalog=xxxxxx;Integrated Security=True" />
    <KplusConnectionString value="Driver={Adaptive Server Enterprise};UID=xxxxx;PWD=xxxxx;Database=xxxxxx;Server=xxxxx;Port=4130;" />
    <LogFiles value="true" />
  </KPlusSynchronizerConsole.Properties.Settings>
</ServiceSettings>

if you look at your spec:

<sectionGroup name="ServiceSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
  <section name="KPlusSynchronizerConsole.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>

it should be clear that you are telling it to expect a section named "KPlusSynchronizerConsole.Properties.Settings" and thus you should have one!

You need to do that same to

<TablesToSynchronize>...
tolanj
  • 3,651
  • 16
  • 30