में app.config का उपयोग करना मुझे समस्या है। मैं नेट कोर (सी #) जो इस तरह app.config का उपयोग में एक प्रोग्राम लिखने के लिए की जरूरत है:.Net कोर
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="custom" type="ConfigurationSample.CustomConfigurationSection, ConfigurationSample"/>
</configSections>
<connectionStrings>
<add name="sampleDatabase" connectionString="Data Source=localhost\SQLExpress;Initial Catalog=SampleDatabase;Integrated Security=True"/>
</connectionStrings>
<appSettings>
<add key="sampleApplication" value="Configuration Sample"/>
</appSettings>
<custom>
<customConfigurations>
<add key="customSample" name="Mickey Mouse" age="83"/>
</customConfigurations>
</custom>
</configuration>
और मैं लिखने:
string connectionString = ConfigurationManager.ConnectionStrings["sampleDatabase"].ConnectionString;
Console.WriteLine(connectionString);
// read appSettings configuration
string appSettingValue = ConfigurationManager.AppSettings["sampleApplication"];
Console.WriteLine(appSettingValue);
और यह इंटरनेट से उदाहरण है इसलिए मैंने सोचा कि होगा काम है, लेकिन मैं अपवाद हो रही है:
System.Configuration.ConfigurationErrorsException: 'Error Initializing the configuration system.'
Inner Exception
TypeLoadException: Could not load type 'System.Configuration.InternalConfigurationHost' from assembly 'CoreCompat.System.Configuration, Version=4.2.3.0, Culture=neutral, PublicKeyToken=null' because the method 'get_bundled_machine_config' has no implementation (no RVA).
मैं NuGet के माध्यम से डाउनलोड किया - स्थापित करें-पैकेज CoreCompat.System.Configuration -संस्करण 4.2.3-r4 -पूर्व और अभी भी काम नहीं करते। शायद कोई मेरी मदद कर सकता है?
मुझे लगता है कि नेट नेट के लिए आप कॉन्फ़िगरेशन के लिए जेसन फाइलों का उपयोग करेंगे। उस पर देखो। – Phiter
.NET कोर में आप appsettings.json का उपयोग करते हैं, app.config नहीं। –
लेकिन मैंने नेट कोर के बारे में कहा और एएसपी.Net कोर – Nju