在 Visual Studio 2015 中创建了一个 C# 服务项目,将其从各种代码源组合在一起。
\n\n它编译了,我可以安装该服务,并且可以启动该服务,但该服务不会\xe2\x80\x99t触发逻辑。它应该只查看特定文件夹中的 XML 文件,然后将它们上传到 FTP 站点。
\n\n我添加了一个记录器,它一致地写出以下错误:
\n\n\n\n\nFTP 上传服务启动于 05/08/2016 10:44:42 AM FTP 上传服务\n 错误发生于: 05/08/2016 10:44:42 AM 配置系统无法在\n System.Configuration.ClientConfigurationSystem 初始化。 EnsureInit(String\n configKey) 位于\n System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String\nsectionName) 位于\n System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String\nsectionName) 位于\n System.Configuration.ConfigurationManager.get_AppSettings() at\n FTPUploadService.Service1.ScheduleService() in\n C:\\user\\Desktop\\FTPUploadService\\FTPUploadService\\FTPUploadService\\Service1.cs:line\n 51
\n
我转到代码中的这一特定行(第 51 行),即:
\n\nstring mode = ConfigurationManager.AppSettings["Mode"].ToUpper();\nRun Code Online (Sandbox Code Playgroud)\n\n这里有更多的代码块供参考:
\n\ntry\n {\n Scheduler = new Timer(new TimerCallback(SchedulerCallback));\n string mode = ConfigurationManager.AppSettings["Mode"].ToUpper();\n this.WriteToFile("FTP Upload Service Mode: " + mode + " {0}");\n\n //Set the …Run Code Online (Sandbox Code Playgroud) c# ×1