简体   繁体   English

服务结构和IConfigurationBuilder

[英]Service Fabric and IConfigurationBuilder

I'm trying to use IConfigurationBuilder for purses of reading xml configuration. 我正在尝试使用IConfigurationBuilder来读取xml配置。 However when the service runs (once deployed) it fails at this line: 但是,当服务运行(一旦部署)时,它将在以下行失败:

 private static void Main()
        {
            try
            {
                IConfigurationBuilder Builder = new ConfigurationBuilder(); // Exception here
                ..
                ServiceRuntime.RegisterServiceAsync("MyService.ServiceType",
                        context => new Service(
                            context)
                    .GetAwaiter().GetResult();

On the server I see this exception in Application Logs: 在服务器上,我在应用程序日志中看到此异常:

Description: The process was terminated due to an unhandled exception. 说明:由于未处理的异常,进程已终止。 Exception Info: System.IO.FileNotFoundException at MyService.Program.Main() 异常信息:MyService.Program.Main()上的System.IO.FileNotFoundException

If I remove this line it works fine. 如果我删除此行,它将正常工作。

And it does WORK fine when I run the service locally from VS. 当我从VS本地运行服务时,它确实工作正常。

To load the service fabric setting file at run time or to use custom file as setting can use ConfigurationProvider class. 若要在运行时加载服务结构设置文件或将自定义文件用作设置,可以使用ConfigurationProvider类。 for reference click here . 供参考单击这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM