Enable Javascript

Please enable Javascript to view website properly

Toll Free 1800 889 7020

Looking for an Expert Development Team? Take two weeks Trial! Try Now

Alternate Approaches to the Plugins Unsecured and Secured Configs (Using JSON File in Plugin Assembly)

Secured and Unsecured Config

Secured and Unsecured Config is used to keep the configuration data that is being used inside the plugin code and we don’t want to have those as the hardcode in the code. As and when there is a lot of custom extension required in a project, we require having an ample amount of plugins registered for functionality extension and at the same time, it becomes difficult to keep the configuration data in the code repository as it would need to have multiple Config files maintained. On the other hand, if we don’t keep Config inside the code repository, there might be chances of losing those on the application crash.

While working, if Dynamics CRM Consultants using Unsecured/Secured Config, just to avoid hardcoded in our plugin code, and for better code structure, rather than using Unsecured/Secured Config, we can have a JSON file inside the plugin project.

Alternate Approaches

But, as the separate file cannot be registered to the CRM server, we need to go through the following steps to embed the file into assembly itself.


  • 1. Put all the configurations into JSON format and segregate those into that JSON file either categorizing by entity name or event or both. Like, if we have an unsecured configuration with a plugin step registered on the Account entity and also have a configuration on the opportunity entity, we can define our JSON as follows.

    { "Account":[ { "uniqueNamePrefix":"IND" } ], "Opportunity":[ { "uniqueNamePrefix":"IND" } ] }
  • 2. Add the JSON file into the plugin project and go to the properties of the included file to set the Build Action as “Embedded Resource”.

    Alternate Approaches
  • 3. The following function is used to read the file. The file name in the below code should be replaced with the Plugin assembly name.<folder in which file is kept inside>.<Resource Name or JSON file name>

    In the below example, “OrganizationName.Cme.Dyn.Plugins” is the assembly name. “Data” is the first folder and “JSON” is the folder into “Data”, and the JSON file is kept there itself.

    Alternate Approaches
  • 4. Retuned Byte stream from the above-mentioned function can be converted into JSON format using JSON serialize to get the values from the configurations.


Rather than using Unsecured/Secured configurations, we can have JSON files embedded with assembly to keep all the hardcode values which can be easily maintained in the code repository.

Recent Blogs


NSS Note

Some of our clients