Y'herd thisun? 

“Want to hear the last-ever space shuttle landing sonic booms echoing across the Los Angeles basin? It's neat!”

from this av page by smith

Remote configs for dlls & autodeploys

TaggedCoding, DotNet

DLLs & AutoDeploys can have Config files too

Config files for .Net programs are great, just stick your required dynamic information (connect strings, global defaults, etc) in an XML file in the same location as your executable and read them with the built-in methods.

But there are limitations:

1) By default, they're only for exe's, dlls can't use them

2) An AutoDeploy app is hosted in a special cache on the user machine, and the config from the server location doesn't follow it around.

There are a number of tricks out there to get at that information but the easiest is to save your settings at the source file server location in the XML format that a DataSet can read, appending a custom extenstion to the file name (such as ".cfg"). Then in your AutoDeployed applets' Form_Load or in an instantiated objects' constructor use ds.ReadXML passing the CodeBase property of the assembly and the appended custom extension.

The values then can be read using standard DataSet methods.

The reason for the custom extension, as opposed to using the established ".config" is that AutoDeploy applets are held in IIS Virtual Directories and if the runtimes are installed on the IIS machine then files ending with ".config" will most likely be protected and not allowed to be read remotely.

Hope that helps.

Robert Smith
Kirkland, WA

home     who is smith    contact smith     rss feed π
Since 1997 a place for my stuff, and it if helps you too then all the better