*Version: Tridion 2009 *
I have added a Custom Configuration section in Tridion.ContentManager.Config for storing some values to be used by the Custom Resolver that I'm writing.

I will use this value to detect whether the current publish transaction is executing against the live publication target or not.

However, when I attempt to retrieve the values from the config file, I get "Object reference not set to an instance of an object." error.

This is how the configuration looks like:

            <!-- Other Config Section Declarations -->     
            <section name="My.ConfigSection" 
                     type="System.Configuration.NameValueSectionHandler" />
                <add key="LivePublicationTargetId" 
                     value="tcm:0-10-65537" />
        <!-- Other Config Sections-->

This is how I try to retrieve it from the IResolver class: (Please note that this is working for regular ASP.net websites.)

string LivePubTargetID = ((NameValueCollection)ConfigurationManager.

This is the piece that returns null and causes the error: ConfigurationManager.GetSection("My.ConfigSection").

Any ideas about how to overcome this issue?

  • Check your config file for non-printing characters.
    – oic
    Mar 30, 2013 at 13:01
  • thanx Oic, but the config file seems to be ok. I have eventually modified it with Visual Studi, plus the "custom resolving mappings" that are done in very same config file seem to be accurate. Apr 2, 2013 at 12:14

4 Answers 4


Could you please break your code down by this way -

NameValueCollection section = (NameValueCollection)ConfigurationManager.GetSection("My.ConfigSection");

string liveTargetId= section["LivePublicationTargetId"];

By this way you can easily find out where exactly NULL exists, in “section” or “LivePublicationTargetId”.

Please update me about this. I will take next step on this behalf and update the answer here.

  • I have already done that. It's the "section" that doesn't exist (that is null) Apr 2, 2013 at 12:07

As far as I know, Tridion.ContentManager.config isn't loaded by the ConfigurationManager class. Even if it was, I would not recommend putting your own stuff into it as it will likely get overwritten the next time you upgrade.

Put it in your own App.config file instead; that should work with the code you have.

  • Hi Peter, Thanks for the answer. That's what I have eventually what I've done (kind of). Since there was no App.config file available, I've created and used my own config file. Apr 17, 2013 at 14:14
  • But the online docs, certainly for Tridion 2011 SP1 say "If your custom resolver also requires configuration, SDL Tridion expects to find such configuration in the same Tridion.ContentManager.config file".
    – Neil
    Apr 21, 2013 at 20:37

I ended up using my own configuration file for this. I would like to share with you.

        string livePublicationTargetId = "";
        private string LivePublicationTargetId
                if (String.IsNullOrEmpty(livePublicationTargetId))

                    //get the dll path: first parse it as URI to get rid off ///file: prefix and then HTTP decode
                    string assemblyFile = System.Web.HttpUtility.UrlDecode((new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);

                    ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();

                    //set ExeConfigFile name : use the assemblyname but replace '.dll' with '.config'
                    configMap.ExeConfigFilename = assemblyFile.Substring(0, assemblyFile.LastIndexOf('.')) + ".config";

                    //init config object
                    Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
                    if (!config.HasFile) throw new System.IO.FileNotFoundException(String.Format("Config file '{0}' doesn't exist", configMap.ExeConfigFilename));

                    //try reading the config value. It will throw error if it can't be found/read.             
                    livePublicationTargetId = ((ClientSettingsSection)config.GetSection("applicationSettings/MyClient.Tridion.CustomResolving.Properties.Settings"))

                return livePublicationTargetId;


Try this way:

private void ReadSettings() {
    NameValueCollection myConfigSection = (NameValueCollection)ConfigurationSettings.GetConfig("My.ConfigSection");
    LivePubTargetID = myConfigSection["LivePublicationTargetId"].toString(); 

One more information, If you want to read the values from a file other than the app.config, you need to load it into the ConfigurationManager.

Try using this method: ConfigurationManager.OpenMappedExeConfiguration()

  • Nope, the outcome is not different. ConfigurationSettings.GetConfig() is obsolete and replaced with ConfigurationManager.GetSection() in .net 2.0. I gave it a try but doesn't work : ConfigurationSettings.GetConfig("My.ConfigSection") also returns null Mar 30, 2013 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.