I'm testing some code here, trying to get it to work with CAS. I have a configuration file at a file location with some WCF definitions. I load this code with:
var config = ConfigurationManager.OpenExeConfiguration(@"C:\path\client.config");
which works just fine. I can also load it with File.ReadAllText(...), as I've added the CAS permissions to read the file. However when I call:
ConfigurationSection section = config.GetSection("system.serviceModel/client");
I get a security exception that I'm not allowed to read the section. Is there a way around this without modifying machine.config. The config class is passed to a WCF proxy class.
My other option is to recreate the WCF proxy class, reading the .config file as xml and manually set all the properties A lot more work.
Or I'll give up and just GAC it instead. But I hate to give up.