Configuration file for CRM 3.0 Callouts

Hi,

In callouts in CRM 3.0, for providing configuration information we used to create our own config file.

The naming convention that we used to follow was

AssemblyName.dll.Config

And we used to deploy it at the same location as callout i.e. server/bin/assembly

The structure of the config file used to be

<?xml version=”1.0″ encoding=”utf-8″ ?>
<config>
<crmurl>http://servername:5555/mscrmservices/2006/crmservice.asmx</crmurl&gt;
<loglocation>C:\CrmLog\PluginLog.txt</loglocation>
</config>

To read the config values in the callout we used to have this following code

string assemblyLocation=System.Reflection.Assembly.GetExecutingAssembly().Location;
string crmUrl=GetConfigValue(assemblyLocation,”crmurl”);

The GetConfigValue function

private static string GetConfigValue(string AssemblyName,string KeyValue)
{
string Filename=AssemblyName+”.config”;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Filename);
XmlNode crmNode = xmlDoc.SelectSingleNode(“//”+KeyValue);
string tagValue=crmNode.InnerText.ToString();
return tagValue;

}

Actually I was working with callouts after so many months, so thought i should save the above information for future reference!!

Bye…


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s