Access .NET Framework library from maps
Hi
I'm trying to access System.Configuration.ConfigurationManger.AppSettings from C# code inside map. Compiler throwing error that it can't find ConfigurationManger and classic error of "are you missing assembly reference ?"
I added the System.Configuration.dll to the reference.
Any idea what could be wrong ?
Bhava
Answers
- Hi,You can't use this namespace directly using inline code in scripting functoid. The list of namespaces that you can use directly is limited and listed here (http://technet.microsoft.com/en-us/library/aa561456(BTS.20).aspx)So you will have to create a separate custom helper assembly, put all your logic in there, install the assembly into GAC, reference it from the project which contains the map and use it in the scripting functoid.
Kiryl Kavalenka My Blog- Marked As Answer bybhava Monday, November 09, 2009 12:07 PM
All Replies
- Hi,You can't use this namespace directly using inline code in scripting functoid. The list of namespaces that you can use directly is limited and listed here (http://technet.microsoft.com/en-us/library/aa561456(BTS.20).aspx)So you will have to create a separate custom helper assembly, put all your logic in there, install the assembly into GAC, reference it from the project which contains the map and use it in the scripting functoid.
Kiryl Kavalenka My Blog- Marked As Answer bybhava Monday, November 09, 2009 12:07 PM
- Hi,I am using inline C# scripting functoid. The functoid has one input parameter that is the key name. The code in functoid is as following:public string GetConfigValue(string key){string value = System.Configuration.ConfigurationSettings.AppSettings.Get(key).ToString();return value;}Please make sure that you have the key in devenv.exe.config (normally in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE folder) in case you are testing map in visual studio. At runtime the key should be present in BTSNTSvc.exe.config file.It should work for you. Please inform me if you have any issue.Regards,Tariq Majeed
Please mark it as answer if it helps - Hi,
You can use Tariq suggestion or in the script functoid you can call an external assembly (dll) with you C# function. Note: for deploy you have to put this dll on gac.
Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx - Hi Bhava,
Here are the steps to read config values from BizTalk Maps:
1. Open "BTSNTSvc.exe.config" file from "drive:\Program Files\Microsoft BizTalk Server 2009 ".
2. Add configuration setting there such as -
<appSettings>
<add key="CON" value="Data Source=SQL-SERVERName;Initial Catalog=DBName;Integrated Security=SSPI"/>
</appSettings>
3. In map file, drag and drop script functoid and write following inline c# script.
public string GetConnectionString()
{
string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("CON").ToString();
return connString;
}
Note:- you cannot test config value in map at design time because configuration values are read BTS host at runtime. To test the config value in map at the design time, you will need to add the same configuration string to the visual studio config.
Regards,
Abhijit
Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question- Proposed As Answer byRahulBizTalk Monday, November 09, 2009 6:26 PM

