none
Cannot call AppSettings.Get method in MAP

    Question

  • Hi All,

    How to use System.Configuration.ConfigurationManager.AppSettings.Get method in a MAP in BizTalk Server 2009.

    Using inline C# shows compilation erreur explaining "ConfigurationManager Type or namespace doesn't exist.." even if System.Configuration assembly is referenced.

    I know that a solution would be to use an external C# class but is there a more elegant solution or I made a mistake ?

    Thanks,

    Christophe

    Wednesday, May 12, 2010 1:53 PM

Answers

All replies

  • Hi,

    Please use the following in your C# inlince scripting functoid:

    public string GetConfigValue(string key)
     {
           string value = System.Configuration.ConfigurationSettings.AppSettings.Get(key).ToString();
           return value;
     }

    ConfigurationManager is not available in Map and you can use it in external assembly.  But you can use ConfigurationSettings in inline C# scripting functoid.

    Regards,

    Tariq Majeed

     


    Please mark it as answer if it helps
    Wednesday, May 12, 2010 2:24 PM
  • The thing you are doing is not supported straightforward. BizTalk saves inline scripts in the Extensible Stylesheet Language Transformations (XSLT) stylesheet defining the map. Because of this, inline scripts may use the same namespaces as any other XSLT stylesheet script. See the available Namespace supported.

    You can use some limited types inside inline scripts as per w3c standards like String, Double. Please refer this link in MSDN to know more about XSLT Stylesheet Scripting


    Please mark it as Answer if this answers your question
    Thanks.
    Mo
    The contents I write here is my personal views, not the view of my employer and anyone else.
    Wednesday, May 12, 2010 2:37 PM
  •    

      I would say if you want to store and use any config in BizTalk,  SSO Config store would be the best approach.  Check the following link: http://www.microsoft.com/downloads/details.aspx?FamilyID=94E07DE1-1D33-4245-B430-9216979CD587&displaylang=en&displaylang=en

     - SHR

     

     

     

    Wednesday, May 12, 2010 3:23 PM
  • Hi Christophe,

    As Tarik has suggested you can use System.Configuration.ConfigurationSettings.AppSettings to get to it. This has been discussed in this thread:

    http://social.msdn.microsoft.com/Forums/en/biztalkgeneral/thread/1851a606-9c92-4b46-9541-447dd97c0a67

    And also mentioned in this blog post:

    http://blogs.msdn.com/brajens/archive/2007/01/16/using-configuration-in-biztalk-map.aspx

    Regards,


    Thiago Almeida - http://connectedthoughts.wordpress.com
    Wednesday, May 12, 2010 8:13 PM
    Answerer
  • Hi Chris,

    As mentioned by Tariq and Thiago. 

    System.Configuration.ConfigurationSettings.AppSettings.Get(key).ToString();

    will work perfectly in BizTalk Map. But you cannot test config value in BizTalk map at design time.

    PS: If possible, I would suggest you to store all the BizTalk related config values in SSO database. please go thru the below link to have an idea where to store your custom configuration for a BizTalk solution.

    http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx

    Regards,

    Abhijit

     


    Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question
    Thursday, May 13, 2010 6:43 AM
  • You can test it in the map at design time by adding the config values to the application configuration file for Visual Studio, devenv.exe.config.

    For Visual Studio 2008 this file is usually found here: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

    Regards,


    Thiago Almeida - http://connectedthoughts.wordpress.com
    Thursday, May 13, 2010 7:27 PM
    Answerer
  • Thanks all for your useful answers.

     

    Christophe

     

    Tuesday, May 18, 2010 6:30 AM
  • that helped me wasting more time to find the reason.

    Tuesday, February 22, 2011 3:14 PM
  • What you have suggested will work if we do not use config sections, and direct key is available in AppSettings of BizTalk Config file. But as i have mentioned we are having separate config file which is referred in BizTalk Config. This code is unable to find key and resulting in null reference exception.


    Regards, Dharmendra, Bangalore (India)

    Monday, May 21, 2012 11:07 AM