Reputation: 8618
Simple enough, i'm trying to do this ...
var ftpRequest = (FtpWebRequest)System.Net.FtpWebRequest.Create("ftp://host/folder/");
... and here's the error:
Configuration system failed to initialize at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Net.Configuration.WebRequestModulesSectionInternal.GetSection()
at System.Net.WebRequest.get_PrefixList()
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
Odd that this would require any config info at all but since this is a new app I literally only have a few bits of code and imported the log4net package so my entire config file looks like this ...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<log4net>
<appender name="file" type="log4net.Appender.RollingFileAppender">
<file value="log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<datePattern value="MMM-dd HH:mm" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="file" />
</root>
</log4net>
</configuration>
Is this caused by some need to run this code within the context of a web application running on IIS or something?
Seems pretty weird.
Upvotes: 1
Views: 110
Reputation: 8618
Ok I was an idiot ... Turns out my config was wrong, I hadn't setup log4net right in it:
Unrecognized configuration section log4net
The real error was that, the result being yet more errors that followed ... odd that .Net would continue to run though ... usually it would stop on the first exception hit.
Upvotes: 1