CRM 2013 Plugin :- External connection string from web.config RRS feed

  • Question

  • Respected community members,

    I have bunch of plugins register in IsolationMode="None" registered in databaseMode in CRM 2013 SP1 and have conenction string in Secure config section. 

    I am curious , is it possible to put connection string into MS CRM native web.config file (\\crm server\c$\Program Files\Microsoft Dynamics CRM\CRMWeb\web.config) and accessing that from Plugin??

    Has any one done that or is it not possible??



    Friday, July 25, 2014 3:22 PM

All replies

  • Hi Nick:

    You are not supposed to access the platform or database directly from within a plug-n it can cause deadlocks.  You need to use the context passed to access any platform messages.


    Friday, July 25, 2014 4:56 PM
  • Hi Nick,

    I would not recommend that. Reading a web.config file from Plugin is going to be like reading any other file, so web.config doesn't make anything special. If you're looking for somewhere else to store your configuration other than the secure and unsecure config section, you can try out the registry. However, this will work only for  CRM On-Premise and the registry keys will need to be present in all the CRM servers. We had a similar scenario in one of our projects where some of the configuration was stored in the registry.

    Admin QuikView Solution for CRM 2013

    Friday, July 25, 2014 8:57 PM
  • I think you could use web.config, and access the configuration data, though only for synchronous plugins. However, I'd suggest you use either the secure and unsecure config section of the plugin registration step, or create a 'configuration' entity in CRM, and store the data in there

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, July 28, 2014 3:43 PM
  • Hi Nick,

     Yes, you can put the connection string on your web.config and access it. 

    You are already using a better solution by adding it into secure config section.

    Another option is to create an Entity (called settings or config) that stores the connection string and access it like you access a CRM record from a plugin.



    Wednesday, July 30, 2014 2:29 AM
  • Jithesh, 

    so how do you access the connection string?? i mean can you please share the syntax?

    Wednesday, July 30, 2014 11:56 AM
  • Hi Nick,

     Sorry, for the late reply. I am sure you would have already figured this out.

    If you check your CRM, you could see that  there is an HelpCatalogName app settings in the default CRM 2013 web.config.

    throw new Microsoft.Xrm.Sdk.InvalidPluginExecutionException(ConfigurationManager.AppSettings["HelpCatalogName"]);

    The above code in a plugin showed me string "Microsoft CRM Help" (the value of the key HelpCatalogName).

    the following link will detail more about Configuration Manager - can be used in plugins.


    More detailed steps to get connection strings can be seen in


    Hope this helps.



    Monday, August 4, 2014 2:46 AM