Note that there are some explanatory texts on larger screens.

plurals
  1. POCOM+ Server configuration with custom ConfigurationSection
    primarykey
    data
    text
    <p>I have a COM+ server hosting a .Net component which implements ServicedComponent.</p> <p>The COM+ server needs to access a configuration file in which a custom configuration section has been defined.</p> <p>I can load the configuration fine with the following code:</p> <pre><code>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"); </code></pre> <p>System.InvalidCastException: Unable to cast object of type 'System.Configuration.DefaultSection' to type 'MyProject.MyCustomSettings'</p> <p>Here is how I declared the custom config section in the configuration file:</p> <pre><code>&lt;configSections&gt; &lt;section name="MyProject.MyCustomSettings" type="MyProject.MyCustomSettings, MyProject, Version=1.0.3322.1077, Culture=neutral, PublicKeyToken=176fc8b9840b0b09"/&gt; &lt;/configSections&gt; </code></pre> <p>This case indeed returns a DefaultSection object which does not seem to be of much use since I was expecting a CustomSettings object.</p> <p>Please note that MyProject is strongly named.</p> <p>An option is to install the MyProject.dll assembly in the GAC, but for organisational reasons, this solution is unappealing.</p> <p>Any other suggestion?</p> <p>How can I load a custom configuration section from a given assembly's configuration file from a process running in DLLHost?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload