gh9
gh9

Reputation: 10703

config files and referencing config values inside of them

I have two projects FOO and BAR

Inside of BAR i have a class

public static class CheckInServiceFactory
{
    public static ICheckInService GetInstance()
    {
        var factory = new ChannelFactory<ICheckInService>("CheckInService");
        return factory.CreateChannel();
    }
}

Inside of FOO i have the calling code

var searchResults = CheckInServiceFactory.GetInstance();

Also inside of FOO I have an appconfig which has "CheckInService" endpoint set up.

My question is, How does the CheckInServiceFactory know to lookin in FOO's appconfig for the endpoint?

Why doesn't it look for it in BAR's config file (which btw its not there so i thought this would blow up)

Upvotes: 1

Views: 78

Answers (2)

Nick Butler
Nick Butler

Reputation: 24383

The configuration comes from the application config file.

I presume FOO is the app and BAR is a referenced dll. So the config would be read from FOO.exe.config

Upvotes: 1

John Saunders
John Saunders

Reputation: 161773

All configuration files are always in the executing application. If that's an .EXE file of some sort, then they are in application.exe.config. If it's a web application, then that's web.config.

Library files' (.dll) config are never used.

It has been that way since Day 1.

Upvotes: 2

Related Questions