After adding the appsettings node in App. Config, run the following error to the Conn.Open times:
The type initializer for "System.Transactions.Diagnostics.DiagnosticTrace" throws an exception. "
The problem is resolved after placing the configsections node in the first element under the configuration, for unknown reasons.
Before you change your app. config:
<?xml version= "1.0" encoding= "Utf-8"?
<configuration>
<appsettings
<add key= "buscity" value= "Shanghai, Dongguan, Zhongshan, Lishui, Leshan, Foshan, Baoding, Beihai, Nanjing, Nanchong, Nanning, Nantong, Taizhou, Hefei, Tangshan, Anyang, Yibin, Bazhong, Changzhou, Changde, Guangyuan, Guangzhou, Deyang, Huizhou, Chengdu, Yangzhou, Panzhihua, Kunming, Zhaotong, Hangzhou, Shantou, Jiangmen, Taizhou, Luzhou, Huaian, Shenzhen, Qingyuan, Yantai, Yulin, Zhuhai, Suzhou, Quzhou, Dazhou, Suining, Zhengzhou, Chongqing, Zhenjiang, Changsha, Yangjiang, Yaan, Qingdao, Shaoguan "/>
<add key=" Busid "value=" 398328,595874,662326,280787,352434,601492,357595,355542,293437,390110,354921,489828,280796,390186,622586,338884,352959,34 7956,283053,376904,351940,662530,351110,662499,348289,690040,390582,609990,621734,277073,673785,666466,327372,354010,2825 85,635260,666754,398034,357334,556102,611718,281511,352419,351093,347918,399907,419461,359516,655530,351904,397721,674569 "/>
</appsettings>
<configSections>
<sectiongroup name= "usersettings" type= "System.Configuration.UserSettingsGroup, System, version=2.0.0.0, Culture =neutral, publickeytoken=b77a5c561934e089 ">
<section name= "TrainTickets.Properties.Settings" type= "System.Configuration.ClientSettingsSection, System, version=2.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "allowexedefinition=" MachineToLocalUser " Requirepermission= "false"/>
</sectionGroup>
</configSections>
</configuration>
After you change the app. config:
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<configSections>
<sectiongroup name= "usersettings" type= "System.Configuration.UserSettingsGroup, System, version=2.0.0.0, Culture =neutral, publickeytoken=b77a5c561934e089 ">
<section name= "TrainTickets.Properties.Settings" type= "System.Configuration.ClientSettingsSection, System, version=2.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "allowexedefinition=" MachineToLocalUser " Requirepermission= "false"/>
</sectionGroup>
</configSections> <appSettings>
<add key= "buscity" value= "Shanghai, Dongguan, Zhongshan, Lishui, Leshan, Foshan, Baoding, Beihai, Nanjing, Nanchong, Nanning, Nantong, Taizhou, Hefei, Tangshan, Anyang, Yibin, Bazhong, Changzhou, Changde, Guangyuan, Guangzhou, Deyang, Huizhou, Chengdu, Yangzhou, Panzhihua, Kunming, Zhaotong, Hangzhou, Shantou, Jiangmen, Taizhou, Luzhou, Huaian, Shenzhen, Qingyuan, Yantai, Yulin, Zhuhai, Suzhou, Quzhou, Dazhou, Suining, Zhengzhou, Chongqing, Zhenjiang, Changsha, Yangjiang, Yaan, Qingdao, Shaoguan "/>
<add key= "Busid" value= " 398328,595874,662326,280787,352434,601492,357595,355542,293437,390110,354921,489828,280796,390186,622586,338884,352959,34 7956,283053,376904,351940,662530,351110,662499,348289,690040,390582,609990,621734,277073,673785,666466,327372,354010,2825 85,635260,666754,398034,357334,556102,611718,281511,352419,351093,347918,399907,419461,359516,655530,351904,397721,674569 "/>
</appSettings>
</configuration>
Add appsettings node in app. Config, conn.open times initialization error