Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExeConfigurationFileMap: InvalidArgumentException, The string parameter 'fileMap.ExeConfigFilename' cannot be null or empty

I am getting an InvalidArgumentException when I run my application. I am attempting to create a new ExeConfigurationFileMap, and then load it with ConfigurationManager.

    public static ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\QuikSnap\\QuikSnap.config");
    public static Configuration config = ConfigurationManager.OpenMappedExeConfiguration(Settings.configFile, ConfigurationUserLevel.None);

I have also attempted to set the configuration file after declaring it, but still didn't have any luck.

If I attempt to continue after this exception, I next receive a TypeInitalizationException upon trying to set a variable to one of the values in the configuration file.

like image 562
Michael Avatar asked Apr 12 '26 21:04

Michael


1 Answers

Ran into this same problem. For some ridiculous reason, initializing ExeConfigurationFileMap even with the filepath does not set the property ExeConfigFilename which is required by the Configuration objects constructor. I fixed it by immediately setting that property after instantiating the ExeConfigurationFileMap object like below:

public static ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\QuikSnap\\QuikSnap.config");
configFile.ExeConfigFilename = "QuikSnap.config";
public static Configuration config = ConfigurationManager.OpenMappedExeConfiguration(Settings.configFile, ConfigurationUserLevel.None);
like image 77
user3597116 Avatar answered Apr 15 '26 13:04

user3597116



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!