link common external config files in app.config and web.config

Dec 27 2011

a couple of years ago, i worked on a WCF application. the service library had 3 hosts, web + console + windows service. also, the application made extensive use of logging blocks, exception handling blocks, data blocks & validation application blocks. also, there were unit test projects associated with these projects. at one point, what happened was that the app.config & web.config files of the host projects & unit test projects grew like Topsy.

this is because, apart from the data, exception & logging block sections being huge in the config files, the validation section was the largest. primarily because, we were doing configuration based validation using rule sets. (50-70 fields with 3-4 average validations per field. do the math.)

in order to reduce the size of the files & more importantly, remove the tremendous duplication of the sections, i came across this nice post by Tom. after skimming through the initial part, what i found the most suitable, was using a .NET Framework 2.0 feature, to link external config files.

so this is how a linked app.config or web.config file will look like:

<?xml version=”1.0? encoding=”utf-8??>
<configuration>
  <configSections>
    <section name=”validation” type=”blah” />
    <section name=”loggingConfiguration” type=”blah” />
  </configSections>
  <validation configSource=”validations.config” />
  <loggingConfiguration configSource=”logging.config” />
</configuration>

now you can have common files like data.config, validations.config, logging.config etc. which can be shared by host & unit test projects config files. just ensure, they find each other in the same output directory.

No responses yet

cloud & silverlight

Sep 07 2011

every Cloud has a Silver-Light..

- raja

No responses yet

rebuild indexes for all tables

Feb 24 2011

one of the SQL scripts i always look for is to rebuild indexes, across all tables.

  • there seemed like no simple SQL script to rebuild them in one shot.
  • it was always looping through the tables and running execute sql.

till i stumbled onto this. an undocumented SP to perform dynamic sql, for every table. the keyword being undocumented.. meaning, discretion, disclaimer :)

sp_MSforeachtable @SqlToExecute=”print ‘?’ DBCC DBREINDEX (‘?’)”

as you can see, ‘?’ stands for the table name.

No responses yet

hello world!

Jan 15 2011

geeky habits die hard. this is just a “hello world!” post to test my new blog setup.

looks like the unit test passed!

No responses yet