J'ai un serveur COM + hébergeant un composant .Net qui implémente ServicedComponent.Configuration du serveur COM + avec ConfigurationSection personnalisée
Le serveur COM + doit accéder à un fichier de configuration dans lequel une section de configuration personnalisée a été définie.
je peux charger la configuration fine par le code suivant:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = @"%MY_FOLDER_WITH_ALL_DLLS%\MyComServer.dll.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
// All is fine until the next line:
MyCustomSettings customSettings = (MyCustomSettings)tempConfiguration1.GetSection("customSettings");
System.InvalidCastException: impossible à jeter objet de type 'System.Configuration.DefaultSection' de type '' MyProject.MyCustomSettings
Voici comment je déclarai la section de configuration personnalisée dans le fichier de configuration:
<configSections>
<section name="MyProject.MyCustomSettings" type="MyProject.MyCustomSettings, MyProject, Version=1.0.3322.1077, Culture=neutral, PublicKeyToken=176fc8b9840b0b09"/>
</configSections>
Cette affaire retourne en effet un objet DefaultSection qui doe s ne semble pas être d'une grande utilité car je m'attendais à un objet CustomSettings.
Veuillez noter que MyProject est fortement nommé.
Une option consiste à installer l'assembly MyProject.dll dans le GAC, mais pour des raisons d'organisation, cette solution n'est pas attrayante.
Une autre suggestion?
Comment puis-je charger une section de configuration personnalisée à partir du fichier de configuration d'un assembly donné à partir d'un processus s'exécutant dans DLLHost?
Merci.