locked
How to access app.config keys in registered plugin .dll? RRS feed

  • Question

  • My plugin contains couple of variables:

    string Orgnization_Name ="Org2";
    string url = http://crm:5555/crmservice.asmx?uniquename=org2;


    I register my plugins in Database using Plugin Registration Tool. How can i defined these variables in app.config file? Plugin Registration Tool just requires .dll files and .config file is never asked. Does .dll file contain all the variables defined in app.config file???


    Sohaib Ahmad [Business Management Solution Professional] http://www.solutiontalk.blogspot.com
    Thursday, December 3, 2009 3:33 PM

Answers

  • Hi, Sohaib.

    It seems that you cant use app.config to pass parameters to your plugin...

    But you can use Register or some custom entity in CRM to store this data.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Thursday, December 3, 2009 4:30 PM
    Moderator
  • You can't use the app.config file. You can either read it from the registry or create your custom class to read it from your custom config file that's stored in a custom location on the server.

    I hope this helps.

    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    Thursday, December 3, 2009 4:36 PM
    Moderator

All replies

  • Trough webservices i presume?

    Thursday, December 3, 2009 3:35 PM
  • Hi, Sohaib.

    It seems that you cant use app.config to pass parameters to your plugin...

    But you can use Register or some custom entity in CRM to store this data.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Thursday, December 3, 2009 4:30 PM
    Moderator
  • You can't use the app.config file. You can either read it from the registry or create your custom class to read it from your custom config file that's stored in a custom location on the server.

    I hope this helps.

    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    Thursday, December 3, 2009 4:36 PM
    Moderator
  • You can't use the app.config file. You can either read it from the registry or create your custom class to read it from your custom config file that's stored in a custom location on the server.

    I hope this helps.

    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com

    Haha =)

    I have written same answer earlier then Darren Liu but my reply wasn't marked as an answer.

    Jim, could you explain why?

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Thursday, December 3, 2009 5:04 PM
    Moderator
  • Hi all,

    for configuration purposes in plugins I use the secure/unsecure configuration parameter of the plugin constructor. See http://msdn.microsoft.com/en-us/library/cc468424.aspx
    This has the advantage, that you don't have to care about deploying config files to other servers or clients.
    Thursday, December 3, 2009 5:20 PM
  • @andry: Creating an entity could be a practical thing for declaring shared global variables....Nice one...but in my scenario i've to keep variable like organizationName and CRM web service URL etc as i am working in multi-tannent environment.

    Reading from registry will also be a good option, but will this be a practical solution? I mean registry values can get corrupted...Is it a practiced solution?
    Sohaib Ahmad [Business Management Solution Professional] http://www.solutiontalk.blogspot.com
    Thursday, December 3, 2009 7:06 PM
  • Hi, Sohaib.

    Yes, I use registry to save settings for custom aspx pages for example.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Thursday, December 3, 2009 7:42 PM
    Moderator
  • o'rite. can you share any code example for that?
    Sohaib Ahmad [Business Management Solution Professional] http://www.solutiontalk.blogspot.com
    Friday, December 4, 2009 5:48 AM