I received an error when an referenced .NET Framework 2.0 assembly tried to execute the following line of code in an IIS hosted WCF service:
Error Message:
exePath must be specified when not running inside a stand alone exe.
Source Code:
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Has anyone experienced this issue and do they know how to resolve it?
EDIT: My question is, what is the best way to open a configuration file (app.config and web.config) from a WCF service that is backwards compatible with a .NET 2.0 assembly?
The referenced .NET 2.0 assembly is part of a class library I developed for our enterprise library to handle common taskes. It was intended to be used in ASP.NET and WinForm applications.
Here is the source code I used to determine which type of configuration file to open:
//Open app.config or web.config file
if (HttpContext.Current != null)
this.m_ConfigFile = WebConfigurationManager.OpenWebConfiguration("~");
else
this.m_ConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With