On FeatureActivated event(WebApplication scoped) I want to read the web.config to get from there a connection string. I use the following code to open the web.config:
Configuration rootWebConfig = WebConfigurationManager.OpenWebConfiguration("/", webApplication.Name);
Everything works fine when I activate the feature through the web interface, but when I try to do the same through PowerShell(Enable-SPFeature) the code fails. From what I saw, the code opens a wrong web.config from the path C:\inetpub\wwwroot\web.config(which does not exist) instead of C:\inetpub\wwwroot\wss\VirtualDirectories\\web.config.
Can some one give me any workaround for this problem?