-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathConfigurationManager.xml
More file actions
1087 lines (966 loc) · 61.6 KB
/
Copy pathConfigurationManager.xml
File metadata and controls
1087 lines (966 loc) · 61.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="ConfigurationManager" FullName="System.Configuration.ConfigurationManager">
<TypeSignature Language="C#" Value="public static class ConfigurationManager" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit ConfigurationManager extends System.Object" FrameworkAlternate="net-10.0-pp;net-11.0-pp;netframework-4.6.2-pp;netframework-4.7.1-pp;netframework-4.7.2-pp;netframework-4.7-pp;netframework-4.8.1-pp;netframework-4.8-pp;netstandard-2.0-pp;windowsdesktop-10.0;windowsdesktop-11.0;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
<TypeSignature Language="DocId" Value="T:System.Configuration.ConfigurationManager" />
<TypeSignature Language="VB.NET" Value="Public Class ConfigurationManager" />
<TypeSignature Language="F#" Value="type ConfigurationManager = class" />
<TypeSignature Language="C++ CLI" Value="public ref class ConfigurationManager abstract sealed" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed ConfigurationManager extends System.Object" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="System.Configuration.ConfigurationManager" FromVersion="11.0.0.0" To="System.Configuration" ToVersion="4.0.0.0" FrameworkAlternate="netframework-4.6.2-pp;netframework-4.7.1-pp;netframework-4.7.2-pp;netframework-4.7-pp;netframework-4.8.1-pp;netframework-4.8-pp" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides access to configuration files for client applications. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationManager> class enables you to access machine, application, and user configuration information. This class replaces the <xref:System.Configuration.ConfigurationSettings> class, which is deprecated. For web applications, use the <xref:System.Web.Configuration.WebConfigurationManager> class.
To use the <xref:System.Configuration.ConfigurationManager> class, your project must reference the `System.Configuration` assembly. By default, some project templates, like Console Application, do not reference this assembly so you must manually reference it.
> [!NOTE]
> The name and location of the application configuration file depend on the application's host. For more information, see [Configuring Apps by using Configuration Files](/dotnet/framework/configure-apps/).
You can use the built-in <xref:System.Configuration> types or derive from them to handle configuration information. By using these types, you can work directly with configuration information and you can extend configuration files to include custom information.
The <xref:System.Configuration.ConfigurationManager> class includes members that enable you to perform the following tasks:
- Read a section from a configuration file. To access configuration information, call the <xref:System.Configuration.ConfigurationManager.GetSection*> method. For some sections such as `appSettings` and `connectionStrings`, use the <xref:System.Configuration.ConfigurationManager.AppSettings*> and <xref:System.Configuration.ConfigurationManager.ConnectionStrings*> classes. These members perform read-only operations, use a single cached instance of the configuration, and are multithread aware.
- Read and write configuration files as a whole. Your application can read and write configuration settings at any level, for itself or for other applications or computers, locally or remotely. Use one of the methods provided by the <xref:System.Configuration.ConfigurationManager> class to open a configuration file such as SampleApp.exe.config. These methods return a <xref:System.Configuration.Configuration> object that in turn exposes methods and properties you can use to work with the associated configuration files. The methods perform read or write operations and create the configuration data every time that a file is written.
- Support configuration tasks. The following types are used to support various configuration tasks:
- <xref:System.Configuration.SectionInformation>
- <xref:System.Configuration.PropertyInformation>
- <xref:System.Configuration.PropertyInformationCollection>
- <xref:System.Configuration.ElementInformation>
- <xref:System.Configuration.ContextInformation>
- <xref:System.Configuration.ConfigurationSectionGroup>
- <xref:System.Configuration.ConfigurationSectionGroupCollection>
In addition to working with existing configuration information, you can create and work with custom configuration elements by extending the built-in configuration types such as the <xref:System.Configuration.ConfigurationElement>, <xref:System.Configuration.ConfigurationElementCollection>, <xref:System.Configuration.ConfigurationProperty>, and <xref:System.Configuration.ConfigurationSection> classes. For an example of how to extend a built-in configuration type programmatically, see <xref:System.Configuration.ConfigurationSection>. For an example of how to extend a built-in configuration type that uses the attribute-based model, see <xref:System.Configuration.ConfigurationElement>.
## Examples
The first example shows a simple console application that reads application settings, adds a new setting, and updates an existing setting.
```csharp
using System;
using System.Configuration;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ReadAllSettings();
ReadSetting("Setting1");
ReadSetting("NotValid");
AddUpdateAppSettings("NewSetting", "May 7, 2014");
AddUpdateAppSettings("Setting1", "May 8, 2014");
ReadAllSettings();
}
static void ReadAllSettings()
{
try
{
var appSettings = ConfigurationManager.AppSettings;
if (appSettings.Count == 0)
{
Console.WriteLine("AppSettings is empty.");
}
else
{
foreach (var key in appSettings.AllKeys)
{
Console.WriteLine("Key: {0} Value: {1}", key, appSettings[key]);
}
}
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error reading app settings");
}
}
static void ReadSetting(string key)
{
try
{
var appSettings = ConfigurationManager.AppSettings;
string result = appSettings[key] ?? "Not Found";
Console.WriteLine(result);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error reading app settings");
}
}
static void AddUpdateAppSettings(string key, string value)
{
try
{
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
if (settings[key] == null)
{
settings.Add(key, value);
}
else
{
settings[key].Value = value;
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error writing app settings");
}
}
}
}
```
```vb
Imports System.Configuration
Module Module1
Sub Main()
ReadAllSettings()
ReadSetting("Setting1")
ReadSetting("NotValid")
AddUpdateAppSettings("NewSetting", "May 7, 2014")
AddUpdateAppSettings("Setting1", "May 8, 2014")
ReadAllSettings()
End Sub
Sub ReadAllSettings()
Try
Dim appSettings = ConfigurationManager.AppSettings
If appSettings.Count = 0 Then
Console.WriteLine("AppSettings is empty.")
Else
For Each key As String In appSettings.AllKeys
Console.WriteLine("Key: {0} Value: {1}", key, appSettings(key))
Next
End If
Catch e As ConfigurationErrorsException
Console.WriteLine("Error reading app settings")
End Try
End Sub
Sub ReadSetting(key As String)
Try
Dim appSettings = ConfigurationManager.AppSettings
Dim result As String = appSettings(key)
If IsNothing(result) Then
result = "Not found"
End If
Console.WriteLine(result)
Catch e As ConfigurationErrorsException
Console.WriteLine("Error reading app settings")
End Try
End Sub
Sub AddUpdateAppSettings(key As String, value As String)
Try
Dim configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim settings = configFile.AppSettings.Settings
If IsNothing(settings(key)) Then
settings.Add(key, value)
Else
settings(key).Value = value
End If
configFile.Save(ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name)
Catch e As ConfigurationErrorsException
Console.WriteLine("Error writing app settings")
End Try
End Sub
End Module
```
The following example shows how to use a connection string to read data from a database.
```csharp
using System;
using System.Configuration;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ReadProducts();
}
static void ReadProducts()
{
var connectionString = ConfigurationManager.ConnectionStrings["WingtipToys"].ConnectionString;
string queryString = "SELECT Id, ProductName FROM dbo.Products;";
using (var connection = new SqlConnection(connectionString))
{
var command = new SqlCommand(queryString, connection);
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}", reader[0], reader[1]));
}
}
}
}
}
}
```
```vb
Imports System.Configuration
Imports System.Data.SqlClient
Module Module1
Sub Main()
ReadProducts()
End Sub
Sub ReadProducts()
Dim connectionString = ConfigurationManager.ConnectionStrings("WingtipToys").ConnectionString
Dim queryString = "SELECT Id, ProductName FROM dbo.Products;"
Using connection As New SqlConnection(connectionString)
Dim command = New SqlCommand(queryString, connection)
connection.Open()
Using reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", reader(0), reader(1)))
End While
End Using
End Using
End Sub
End Module
```
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>The <see cref="T:System.Configuration.Configuration" /> class enables programmatic access for editing configuration files. You use one of the <c>Open</c> methods provided by <see cref="T:System.Configuration.ConfigurationManager" />. These methods return a <see cref="T:System.Configuration.Configuration" /> object, which in turn provides the required methods and properties to handle the underlying configuration files. You can access these files for reading or writing.
To read the configuration files, use <see cref="M:System.Configuration.Configuration.GetSection(System.String)" /> or <see cref="M:System.Configuration.Configuration.GetSectionGroup(System.String)" />. The user or process that reads must have the following permissions:
- Read permission on the configuration file at the current configuration hierarchy level.
- Read permissions on all the parent configuration files.
If your application needs read-only access to its own configuration, we recommend that you use the <see cref="M:System.Configuration.ConfigurationManager.GetSection(System.String)" /> method. This method provides access to the cached configuration values for the current application, which has better performance than the <see cref="T:System.Configuration.Configuration" /> class.
To write to the configuration files, use one of the <see cref="Overload:System.Configuration.Configuration.Save" /> methods. The user or process that writes must have the following permissions:
- Write permission on the configuration file and directory at the current configuration hierarchy level.
- Read permissions on all the configuration files.</para>
</block>
<altmember cref="T:System.Configuration.Configuration" />
<related type="Article" href="/dotnet/framework/configure-apps/">Configuration Files</related>
</Docs>
<Members>
<Member MemberName="AppSettings">
<MemberSignature Language="C#" Value="public static System.Collections.Specialized.NameValueCollection AppSettings { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Collections.Specialized.NameValueCollection AppSettings" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationManager.AppSettings" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property AppSettings As NameValueCollection" />
<MemberSignature Language="F#" Value="static member AppSettings : System.Collections.Specialized.NameValueCollection" Usage="System.Configuration.ConfigurationManager.AppSettings" />
<MemberSignature Language="C++ CLI" Value="public:
 static property System::Collections::Specialized::NameValueCollection ^ AppSettings { System::Collections::Specialized::NameValueCollection ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.Specialized.NameValueCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the <see cref="T:System.Configuration.AppSettingsSection" /> data for the current application's default configuration.</summary>
<value>The contents of the <see cref="T:System.Configuration.AppSettingsSection" /> object for the current application's default configuration.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
An <xref:System.Configuration.AppSettingsSection> object contains the contents of the configuration file's `appSettings` section.
## Examples
The first example shows a simple console application that reads application settings, adds a new setting, and updates an existing setting.
```csharp
using System;
using System.Configuration;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ReadAllSettings();
ReadSetting("Setting1");
ReadSetting("NotValid");
AddUpdateAppSettings("NewSetting", "May 7, 2014");
AddUpdateAppSettings("Setting1", "May 8, 2014");
ReadAllSettings();
}
static void ReadAllSettings()
{
try
{
var appSettings = ConfigurationManager.AppSettings;
if (appSettings.Count == 0)
{
Console.WriteLine("AppSettings is empty.");
}
else
{
foreach (var key in appSettings.AllKeys)
{
Console.WriteLine("Key: {0} Value: {1}", key, appSettings[key]);
}
}
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error reading app settings");
}
}
static void ReadSetting(string key)
{
try
{
var appSettings = ConfigurationManager.AppSettings;
string result = appSettings[key] ?? "Not Found";
Console.WriteLine(result);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error reading app settings");
}
}
static void AddUpdateAppSettings(string key, string value)
{
try
{
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
if (settings[key] == null)
{
settings.Add(key, value);
}
else
{
settings[key].Value = value;
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error writing app settings");
}
}
}
}
```
```vb
Imports System.Configuration
Module Module1
Sub Main()
ReadAllSettings()
ReadSetting("Setting1")
ReadSetting("NotValid")
AddUpdateAppSettings("NewSetting", "May 7, 2014")
AddUpdateAppSettings("Setting1", "May 8, 2014")
ReadAllSettings()
End Sub
Sub ReadAllSettings()
Try
Dim appSettings = ConfigurationManager.AppSettings
If appSettings.Count = 0 Then
Console.WriteLine("AppSettings is empty.")
Else
For Each key As String In appSettings.AllKeys
Console.WriteLine("Key: {0} Value: {1}", key, appSettings(key))
Next
End If
Catch e As ConfigurationErrorsException
Console.WriteLine("Error reading app settings")
End Try
End Sub
Sub ReadSetting(key As String)
Try
Dim appSettings = ConfigurationManager.AppSettings
Dim result As String = appSettings(key)
If IsNothing(result) Then
result = "Not found"
End If
Console.WriteLine(result)
Catch e As ConfigurationErrorsException
Console.WriteLine("Error reading app settings")
End Try
End Sub
Sub AddUpdateAppSettings(key As String, value As String)
Try
Dim configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim settings = configFile.AppSettings.Settings
If IsNothing(settings(key)) Then
settings.Add(key, value)
Else
settings(key).Value = value
End If
configFile.Save(ConfigurationSaveMode.Modified)
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name)
Catch e As ConfigurationErrorsException
Console.WriteLine("Error writing app settings")
End Try
End Sub
End Module
```
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">Could not retrieve a <see cref="T:System.Collections.Specialized.NameValueCollection" /> object with the application settings data.</exception>
<altmember cref="T:System.Configuration.AppSettingsSection" />
<altmember cref="T:System.Collections.Specialized.NameValueCollection" />
</Docs>
</Member>
<Member MemberName="ConnectionStrings">
<MemberSignature Language="C#" Value="public static System.Configuration.ConnectionStringSettingsCollection ConnectionStrings { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Configuration.ConnectionStringSettingsCollection ConnectionStrings" />
<MemberSignature Language="DocId" Value="P:System.Configuration.ConfigurationManager.ConnectionStrings" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property ConnectionStrings As ConnectionStringSettingsCollection" />
<MemberSignature Language="F#" Value="static member ConnectionStrings : System.Configuration.ConnectionStringSettingsCollection" Usage="System.Configuration.ConfigurationManager.ConnectionStrings" />
<MemberSignature Language="C++ CLI" Value="public:
 static property System::Configuration::ConnectionStringSettingsCollection ^ ConnectionStrings { System::Configuration::ConnectionStringSettingsCollection ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.ConnectionStringSettingsCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the <see cref="T:System.Configuration.ConnectionStringsSection" /> data for the current application's default configuration.</summary>
<value>The contents of the <see cref="T:System.Configuration.ConnectionStringsSection" /> object for the current application's default configuration.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A <xref:System.Configuration.ConnectionStringsSection> object contains the contents of the configuration file's `connectionStrings` section.
## Examples
The following example shows how to use a connection string to read data from a database.
```csharp
using System;
using System.Configuration;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ReadProducts();
}
static void ReadProducts()
{
var connectionString = ConfigurationManager.ConnectionStrings["WingtipToys"].ConnectionString;
string queryString = "SELECT Id, ProductName FROM dbo.Products;";
using (var connection = new SqlConnection(connectionString))
{
var command = new SqlCommand(queryString, connection);
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}", reader[0], reader[1]));
}
}
}
}
}
}
```
```vb
Imports System.Configuration
Imports System.Data.SqlClient
Module Module1
Sub Main()
ReadProducts()
End Sub
Sub ReadProducts()
Dim connectionString = ConfigurationManager.ConnectionStrings("WingtipToys").ConnectionString
Dim queryString = "SELECT Id, ProductName FROM dbo.Products;"
Using connection As New SqlConnection(connectionString)
Dim command = New SqlCommand(queryString, connection)
connection.Open()
Using reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(String.Format("{0}, {1}", reader(0), reader(1)))
End While
End Using
End Using
End Sub
End Module
```
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">Could not retrieve a <see cref="T:System.Configuration.ConnectionStringSettingsCollection" /> object.</exception>
<altmember cref="T:System.Configuration.ConnectionStringsSection" />
<altmember cref="T:System.Configuration.ConnectionStringSettingsCollection" />
</Docs>
</Member>
<Member MemberName="GetSection">
<MemberSignature Language="C#" Value="public static object GetSection (string sectionName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig object GetSection(string sectionName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.GetSection(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetSection (sectionName As String) As Object" />
<MemberSignature Language="F#" Value="static member GetSection : string -> obj" Usage="System.Configuration.ConfigurationManager.GetSection sectionName" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Object ^ GetSection(System::String ^ sectionName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sectionName" Type="System.String" />
</Parameters>
<Docs>
<param name="sectionName">The configuration section path and name. Node names are separated by forward slashes, for example "system.net/mailSettings/smtp".</param>
<summary>Retrieves a specified configuration section for the current application's default configuration.</summary>
<returns>The specified <see cref="T:System.Configuration.ConfigurationSection" /> object, or <see langword="null" /> if the section does not exist.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For client applications, this method retrieves a configuration file obtained by merging the application configuration file, the local user configuration file, and the roaming configuration file.
The <xref:System.Configuration.ConfigurationManager.GetSection*> method accesses run-time configuration information that it cannot change. To change the configuration, you use the <xref:System.Configuration.Configuration.GetSection*> method on the configuration file that you obtain by using one of the following methods:
- <xref:System.Configuration.ConfigurationManager.OpenExeConfiguration*>
- <xref:System.Configuration.ConfigurationManager.OpenMachineConfiguration*>
- <xref:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration*>
## Examples
The following example shows how to use the <xref:System.Configuration.ConfigurationManager.GetSection*> method. The example is part of a larger example that is provided for the <xref:System.Configuration.ConfigurationManager> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/CS/configurationmanager.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/VB/configurationmanager.vb" id="Snippet7":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
<block subset="none" type="overrides">
<para>You must cast the return value to the expected configuration type. To avoid possible casting exceptions, you should use a conditional casting operation such as the <see langword="as" /> operator in C# or the <see href="/dotnet/visual-basic/language-reference/operators/trycast-operator">TryCast</see> function in Visual Basic.</para>
</block>
<altmember cref="T:System.Configuration.ConfigurationSection" />
</Docs>
</Member>
<MemberGroup MemberName="OpenExeConfiguration">
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Opens the specified client configuration file as a <see cref="T:System.Configuration.Configuration" /> object.</summary>
</Docs>
</MemberGroup>
<Member MemberName="OpenExeConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenExeConfiguration (System.Configuration.ConfigurationUserLevel userLevel);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenExeConfiguration(valuetype System.Configuration.ConfigurationUserLevel userLevel) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenExeConfiguration (userLevel As ConfigurationUserLevel) As Configuration" />
<MemberSignature Language="F#" Value="static member OpenExeConfiguration : System.Configuration.ConfigurationUserLevel -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenExeConfiguration userLevel" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenExeConfiguration(System::Configuration::ConfigurationUserLevel userLevel);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.Configuration</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="userLevel" Type="System.Configuration.ConfigurationUserLevel" />
</Parameters>
<Docs>
<param name="userLevel">One of the enumeration values that specifies the user level for which you are opening the configuration.</param>
<summary>Opens the configuration file for the current application as a <see cref="T:System.Configuration.Configuration" /> object.</summary>
<returns>The configuration file for the current application.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Client applications use a global configuration that applies to all users, separate configurations that apply to individual users, and configurations that apply to roaming users. The `userLevel` parameter determines the location of the configuration file being opened by indicating whether it has no user level (the configuration file is in the same directory as the application) or has a per-user level (the configuration file is in an application settings path determined by the user level).
Specify which configuration to get by passing one of the following values for `userLevel`:
- To get the <xref:System.Configuration.Configuration> object that applies to all users, set `userLevel` to <xref:System.Configuration.ConfigurationUserLevel.None>.
- To get the local <xref:System.Configuration.Configuration> object that applies to the current user, set `userLevel` to <xref:System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal>.
- To get the roaming <xref:System.Configuration.Configuration> object that applies to the current user, set `userLevel` to <xref:System.Configuration.ConfigurationUserLevel.PerUserRoaming>.
> [!NOTE]
> To get the <xref:System.Configuration.Configuration> object for a resource, your code must have read permissions on all the configuration files from which it inherits settings. To update a configuration file, your code must additionally have write permissions for both the configuration file and the directory in which it exists.
## Examples
The following code example shows how to use the <xref:System.Configuration.ConfigurationManager.OpenExeConfiguration*> method.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/CS/configurationmanager.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/VB/configurationmanager.vb" id="Snippet5":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
<altmember cref="T:System.Configuration.ConfigurationUserLevel" />
<altmember cref="T:System.Configuration.Configuration" />
</Docs>
</Member>
<Member MemberName="OpenExeConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenExeConfiguration (string exePath);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenExeConfiguration(string exePath) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenExeConfiguration(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenExeConfiguration (exePath As String) As Configuration" />
<MemberSignature Language="F#" Value="static member OpenExeConfiguration : string -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenExeConfiguration exePath" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenExeConfiguration(System::String ^ exePath);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.Configuration</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="exePath" Type="System.String" />
</Parameters>
<Docs>
<param name="exePath">The path of the executable (exe) file.</param>
<summary>Opens the specified client configuration file as a <see cref="T:System.Configuration.Configuration" /> object.</summary>
<returns>The specified configuration file.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling this method overload is equivalent to calling the <xref:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(System.Configuration.ExeConfigurationFileMap,System.Configuration.ConfigurationUserLevel,System.Boolean)> overload with the `preLoad` parameter set to `false`.
## Examples
The following code example shows how to use the <xref:System.Configuration.ConfigurationManager.OpenExeConfiguration*> method.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/CS/configurationmanager.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/VB/configurationmanager.vb" id="Snippet6":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
<altmember cref="T:System.Configuration.ConfigurationUserLevel" />
<altmember cref="T:System.Configuration.Configuration" />
</Docs>
</Member>
<Member MemberName="OpenMachineConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenMachineConfiguration ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenMachineConfiguration() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenMachineConfiguration" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenMachineConfiguration () As Configuration" />
<MemberSignature Language="F#" Value="static member OpenMachineConfiguration : unit -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenMachineConfiguration " />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.Configuration</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Opens the machine configuration file on the current computer as a <see cref="T:System.Configuration.Configuration" /> object.</summary>
<returns>The machine configuration file.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Machine configuration settings apply to the whole computer and all applications that reside on it, unless overridden for the local application. Machine configuration settings are read from the Machine.config file of the currently running version of .NET Framework. The Machine.config file is located in the following subdirectory:
*%windir%*\Microsoft.NET\Framework\\*version*\config
> [!NOTE]
> To obtain the <xref:System.Configuration.Configuration> object for a resource, your code must have read permissions on all the configuration files from which it inherits settings. To update a configuration file, your code must additionally have write permissions for both the configuration file and the directory in which it exists. It is not possible to access the Machine.config file for other versions of the .NET Framework that might be installed on the computer.
## Examples
The following code example shows how to use the <xref:System.Configuration.ConfigurationManager.OpenMachineConfiguration*> method to obtain all sections that are contained in the configuration file.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/CS/configurationmanager.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/VB/configurationmanager.vb" id="Snippet4":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
<altmember cref="T:System.Configuration.Configuration" />
</Docs>
</Member>
<MemberGroup MemberName="OpenMappedExeConfiguration">
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Opens the specified client configuration file as a <see cref="T:System.Configuration.Configuration" /> object.</summary>
</Docs>
</MemberGroup>
<Member MemberName="OpenMappedExeConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenMappedExeConfiguration (System.Configuration.ExeConfigurationFileMap fileMap, System.Configuration.ConfigurationUserLevel userLevel);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenMappedExeConfiguration(class System.Configuration.ExeConfigurationFileMap fileMap, valuetype System.Configuration.ConfigurationUserLevel userLevel) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(System.Configuration.ExeConfigurationFileMap,System.Configuration.ConfigurationUserLevel)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenMappedExeConfiguration (fileMap As ExeConfigurationFileMap, userLevel As ConfigurationUserLevel) As Configuration" />
<MemberSignature Language="F#" Value="static member OpenMappedExeConfiguration : System.Configuration.ExeConfigurationFileMap * System.Configuration.ConfigurationUserLevel -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenMappedExeConfiguration (fileMap, userLevel)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenMappedExeConfiguration(System::Configuration::ExeConfigurationFileMap ^ fileMap, System::Configuration::ConfigurationUserLevel userLevel);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.Configuration</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="fileMap" Type="System.Configuration.ExeConfigurationFileMap" />
<Parameter Name="userLevel" Type="System.Configuration.ConfigurationUserLevel" />
</Parameters>
<Docs>
<param name="fileMap">The configuration file to use instead of the application default configuration file.</param>
<param name="userLevel">One of the enumeration values that specifies the user level for which you are opening the configuration.</param>
<summary>Opens the specified client configuration file as a <see cref="T:System.Configuration.Configuration" /> object that uses the specified file mapping and user level.</summary>
<returns>The configuration object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationUserLevel> object determines the location of the configuration file being opened. It indicates whether the file has no user level (the configuration file is in the same directory as the application) or has a per-user level (the configuration file is in an application settings path determined by `userLevel`).
> [!NOTE]
> To obtain the <xref:System.Configuration.Configuration> object for a resource, your code must have read permissions on all the configuration files from which it inherits settings. To update a configuration file, your code must additionally have write permissions for both the configuration file and the directory in which it exists.
## Examples
The following code example shows how to use the <xref:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration*> method to obtain all sections that are contained by the configuration file.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/CS/configurationmanager.cs" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Configuration.ConfigurationManager/VB/configurationmanager.vb" id="Snippet9":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
<altmember cref="T:System.Configuration.ConfigurationUserLevel" />
<altmember cref="T:System.Configuration.Configuration" />
</Docs>
</Member>
<Member MemberName="OpenMappedExeConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenMappedExeConfiguration (System.Configuration.ExeConfigurationFileMap fileMap, System.Configuration.ConfigurationUserLevel userLevel, bool preLoad);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenMappedExeConfiguration(class System.Configuration.ExeConfigurationFileMap fileMap, valuetype System.Configuration.ConfigurationUserLevel userLevel, bool preLoad) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(System.Configuration.ExeConfigurationFileMap,System.Configuration.ConfigurationUserLevel,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenMappedExeConfiguration (fileMap As ExeConfigurationFileMap, userLevel As ConfigurationUserLevel, preLoad As Boolean) As Configuration" />
<MemberSignature Language="F#" Value="static member OpenMappedExeConfiguration : System.Configuration.ExeConfigurationFileMap * System.Configuration.ConfigurationUserLevel * bool -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenMappedExeConfiguration (fileMap, userLevel, preLoad)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenMappedExeConfiguration(System::Configuration::ExeConfigurationFileMap ^ fileMap, System::Configuration::ConfigurationUserLevel userLevel, bool preLoad);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.Configuration</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="fileMap" Type="System.Configuration.ExeConfigurationFileMap" Index="0" FrameworkAlternate="net-10.0-pp;net-11.0-pp;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.1-pp;netframework-4.7.2;netframework-4.7.2-pp;netframework-4.7-pp;netframework-4.8;netframework-4.8.1;netframework-4.8.1-pp;netframework-4.8-pp;netstandard-2.0-pp;windowsdesktop-10.0;windowsdesktop-11.0;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
<Parameter Name="userLevel" Type="System.Configuration.ConfigurationUserLevel" Index="1" FrameworkAlternate="net-10.0-pp;net-11.0-pp;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.1-pp;netframework-4.7.2;netframework-4.7.2-pp;netframework-4.7-pp;netframework-4.8;netframework-4.8.1;netframework-4.8.1-pp;netframework-4.8-pp;netstandard-2.0-pp;windowsdesktop-10.0;windowsdesktop-11.0;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
<Parameter Name="preLoad" Type="System.Boolean" Index="2" FrameworkAlternate="net-10.0-pp;net-11.0-pp;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.1-pp;netframework-4.7.2;netframework-4.7.2-pp;netframework-4.7-pp;netframework-4.8;netframework-4.8.1;netframework-4.8.1-pp;netframework-4.8-pp;netstandard-2.0-pp;windowsdesktop-10.0;windowsdesktop-11.0;windowsdesktop-3.0;windowsdesktop-3.1;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
</Parameters>
<Docs>
<param name="fileMap">The configuration file to use instead of the default application configuration file.</param>
<param name="userLevel">One of the enumeration values that specifies the user level for which you are opening the configuration.</param>
<param name="preLoad">
<see langword="true" /> to preload all section groups and sections; otherwise, <see langword="false" />.</param>
<summary>Opens the specified client configuration file as a <see cref="T:System.Configuration.Configuration" /> object that uses the specified file mapping, user level, and preload option.</summary>
<returns>The configuration object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Configuration.ConfigurationUserLevel> object determines the location of the configuration file that is being opened. It indicates whether the file has no user level (the configuration file is in the same directory as the application) or has a per-user level (the configuration file is in an application settings path that is determined by `userLevel`).
> [!NOTE]
> To obtain the <xref:System.Configuration.Configuration> object for a resource, your code must have read permissions on all the configuration files from which it inherits settings. To update a configuration file, your code must additionally have write permissions for both the configuration file and the directory in which it exists.
For a code example, see the <xref:System.Configuration.ConfigurationManager.OpenMappedExeConfiguration*> overload.
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A configuration file could not be loaded.</exception>
</Docs>
</Member>
<Member MemberName="OpenMappedMachineConfiguration">
<MemberSignature Language="C#" Value="public static System.Configuration.Configuration OpenMappedMachineConfiguration (System.Configuration.ConfigurationFileMap fileMap);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Configuration.Configuration OpenMappedMachineConfiguration(class System.Configuration.ConfigurationFileMap fileMap) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(System.Configuration.ConfigurationFileMap)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function OpenMappedMachineConfiguration (fileMap As ConfigurationFileMap) As Configuration" />
<MemberSignature Language="F#" Value="static member OpenMappedMachineConfiguration : System.Configuration.ConfigurationFileMap -> System.Configuration.Configuration" Usage="System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration fileMap" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Configuration::Configuration ^ OpenMappedMachineConfiguration(System::Configuration::ConfigurationFileMap ^ fileMap);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Configuration</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Configuration.ConfigurationManager</AssemblyName>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>