Site Search:
Sign in | Join | Help

Using a configuration file with VS Tools

Last post 09-19-2007 12:58 AM by Steve Gray. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-27-2007 11:27 AM

    Using a configuration file with VS Tools

     

    Sirs:
    Using VS Tools for Dynamics GP, I need to store a user configurable connection string in some sort of app.config file.

    VS Tools is not reading the standard VB app.config file. I see a KB article about a Dynamics.config file, but I don't understand the article.

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    Filed under:
    • 216.64.79.2
  • 06-27-2007 11:28 AM In reply to

    Re: Using a configuration file with VS Tools

    An app.config file is valid to automatically be ready by an application if it's a web app or an app.exe (to have app.exe.config).  In the case of a vstools addin, it is obviously not a web app and it is not an exe.  So both of the "automatic" config file options won't work (myaddin.dll.config  for instance) as I suspect you are attempting to do.

    However, the dynamics.exe could have a config file (there is a published on in 10.0 as dynamics.exe.config) since it is what is running the addins.  For some reason the config file is named dynamics.config and not dynamics.exe.config.

    As the KB explains, you can use .net 2.0 methods to get at the Dynamics.config file provided that the settings exist in your configuration file.  In the example, there is a setting for a web service called GPWebServices_Dynamics_x0020_GP.  There is also a User setting called LastBatch.

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 06-27-2007 11:28 AM In reply to

    Re: Using a configuration file with VS Tools

    Patrick:
    Thanks for the reply, but it does very little to clear up my issue.

    I understand that I can create a dynamics.config file, and should be able to read from it.

    However, in practice, I cannot do it. I don't understand the KB article. There are three sections in the file in the KB article. I don't understand how they relate.

    What is the minimun required in this file? Can I simply have <configuration>
      <configSections>
     <appSettings>
      <add key="OrderType" value="POSINV" />
     </appSettings>
      </configSections>
    </configuration>

    Thanks for your kind help...

     

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 06-27-2007 11:29 AM In reply to

    Re: Using a configuration file with VS Tools

    In your first email, you didn't really ask a specific question and so therefore I didn't have a specific answer.

    You are a little more specific here but again don't show me any of your code that you are using so I have no idea on what you are doing or how you are reading a config file.

    The sample code provided with the article (that shows C# and VB.net) I give a full dynamics.config file (which doesn't exist out of the box) and the exact code on how to read it.  But assuming your code similar what the sample shows and your config file is what I have (or copied from your app.config as I talk about below) then it should all work.

    So to answer your specific question, the "minimum" would probably be the contents of the example config file with the names changed or sections added.  Actually that config file that you see comes right out of my visual studio 2005 so if you would look at your "app.config" in visual studio, that will be the contents of your Dynamics.config file.  Now this is going to get more interesting if multiple developers put their stuff in the dynamics.config and the format of the config file might be a little strange.

    Action:

    Copy your app.config from your visual studio project.  Copy that into the Dynamics.config or just rename the whole file to Dynamics.Config in your Dynamics folder.

     

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.64.79.2
  • 09-19-2007 12:58 AM In reply to

    Re: Using a configuration file with VS Tools

    OK, I got this working, let me summarize:

    Add a reference to 'system.configuration' to your app

    Create an app.config file, add an appsettings section:

      <appSettings>
      <add key="test" value="mykey" />
     </appSettings>

     add code in an event handler to read the config file:

            Dim str As String
            str = Configuration.ConfigurationManager.AppSettings("test")

    Here is the key:

    After publishing your gpaddins code, rename app.config to dynamics.config, and put it in the dynamics/gp directory.

     

     

    Steve Gray, MCDBA
    Technical Editor
    steve@VSToolsForum.com
    • 216.77.101.2
Page 1 of 1 (5 items)