I have a VS solution with following structure:
Library project (.dll)
Application using the #1 library project
I have app.config defined in the application (#2) which defines a SaveLogsToDirectory
path in appSettings. This value is eventually used by the library project to save the logs generated.
Simple use of api System.Configuration.ConfigurationManager.AppSettings["SaveLogsToDirectory"]
in the library fetches the value from app.config.
Library project has a custom System.Configuration.Install.Installer class defined. When the application is uninstalled from windows via Control Panel, I would like the logs generated at path SaveLogsToDirectory to be deleted. Issue is the below code returns null only and only during the uninstall execution
System.Configuration.ConfigurationManager.AppSettings["SaveLogsToDirectory"]
One of the other approaches I tried was using System.Configuration.ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly())
but during uninstall the api Assembly.GetExecutingAssembly()
returns reference to library project.
I need help on how I can access the application assembly from library during uninstall? One thing to mention is that I cannot provide a class path defined in application to OpenExeConfiguration api since the dll can be used by any other application and that other application may not have that class defined.