简体   繁体   中英

Service Fabric and IConfigurationBuilder

I'm trying to use IConfigurationBuilder for purses of reading xml configuration. 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()

If I remove this line it works fine.

And it does WORK fine when I run the service locally from VS.

To load the service fabric setting file at run time or to use custom file as setting can use ConfigurationProvider class. for reference click here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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