RTD initialization

202 views
Skip to first unread message

stu

unread,
Mar 3, 2011, 11:35:19 PM3/3/11
to Excel-DNA
I have had success creating an RTD server which listens to a port and
passes data to a spreadsheet. I have not been able to figure out
other than hard coding it how to pass the address and port to the
server on startup of the add-in. Any ideas? In my normal programming
I use INI files or the like.

Govert van Drimmelen

unread,
Mar 4, 2011, 3:14:09 AM3/4/11
to Excel-DNA
Hi Stuart,

You could use a standard .NET .config file.

1. Make a file called <TheAddInName>.xll.config with this in:
<configuration>
<appSettings>
<add key = "Test" value="Forty-two" />
</appSettings>
</configuration>

2. In your project, add a reference to the System.Configuration
assembly.
3. In your server add some function to access the settings:

internal static string GetAppSetting(string key)
{
object setting =
System.Configuration.ConfigurationManager.AppSettings[key];
if (setting == null)
{
return "!! INVALID KEY !!";
}
return setting.ToString();
}

-Govert

stu

unread,
Mar 4, 2011, 11:55:27 PM3/4/11
to Excel-DNA
Worked like a charm. Sometime the vastness of .NET amazes me.

Thank you

Stuart
Reply all
Reply to author
Forward
0 new messages