I have created a Fiddler extension that is working great. So I decided to add some more functionality, and save user preferences into a configuration file. This works great if I run the extension from its own directory. Eg.I navigate to C:\Users\richa\Documents\Fiddler2\Scripts, and run the application.
However, when Fiddler is run from c:\Programs..., and Fiddler then picks up the extension from my user directory, it fails. It took me awhile to find it, as it fails silently, without any info in Fiddler Logs (and yes I turn up the verbosity)
Here is a screen shot of the error:
I captured this by attaching a debugger to Fiddler... So using System.Configuration is failing when it attempts to open/create/write to a file.
specifically this section of code:
if (_Configuration == null)
{
// Get the current configuration file.
_Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
}
// Add the custom section to the application
// configuration file.
if (_Configuration.Sections[nameof(WebHookParameterSection)] == null)
{
_Configuration.Sections.Add(nameof(WebHookParameterSection), _WebHookConfiguration);
// Save the application configuration file.
_WebConfigurationManagement.SaveWebConfigurationParameters();
}
_WebHookConfiguration = _Configuration.GetSection(nameof(WebHookParameterSection)) as WebHookParameterSection;
So I thought I would need elevated permissions to open/create/write a file from the context of when Fiddler is running from it's installed directory. However, running Fiddler in Admin mode didn't help.
My question is, how can prefs be saved in a Fiddler Extension?
It is hard to say what exactly goes on without having the code of your extension.
The deal is Fiddler loads extensions by reflection. So your extension ends up in Fiddler app domain. Depending on how you use the System.Configuration API you will either read the settings stored in fiddler.exe.config or try modifying it. You probably don't really want that anyways. What prevents you from doing that when running Fiddler as admin is most probably Windows UAC.