Update appSettings in App.Config for executable.

I wanted programmatically (for administrator) to update configuration settings for .Net 2.0 executable.
The new  in VS 2005 Properties.Settings class saves only user-scope settings, not application scope, which is inconvinient.

I’ve decided to use The easiest way to read/write AppSettings   from the very good article Read/Write App.config with .NET 2.0/Enterprise Library   However I noticed two issues:

 config.AppSettings.Settings (KeyValueConfigurationCollection class) has Add and Remove methods, but does not have Set method, so I had to create static helper function:
        public static void Set(KeyValueConfigurationCollection settings, string key, string value)
        {

            if (settings[key] != null)

            {

                settings.Remove(key);

            }

            settings.Add(key, value);

        }

 

Also if the appSettings element uses the File attribute,

config.Save() for executable updates the main file, not specified in File attribute “appSettings” section.So if the value is stored in the referenced file, saving “appSettings” to the main file has no effect.

 

Advertisements

Link to Russian Bard Club in Melbourne.

It’s my second personal/social post in this technical blog.


I am participationg in Russian Bard Club “Southern Cross” . I’ve recently noticed that the club’s web site is not shown in Google. Even if it is out-of-date and not complete, it’s better to have it searchable, because at least some info can be interesting.  I hope that this link will help Google to crawl it.

Dataset.Merge should invoke virtual Table.Clone for copied tables.

In my previous post I described a problem when Typed Dataset merged into un-typed dataset.
I’ve reviewed  the code of Dataset.Merge using Reflector and found, that if table doesn’t exist in the current dataset,  Table.Clone is called(in internal private DataTable Merger.MergeSchema function) to add a new table to the dataset.Unfortunately,they do not call virtual Table.Clone() method, that is overridden by the derived typed dataset, but use


internal DataTable Clone(DataSet cloneDS),which can’t be overridden by the derived class.


Dataset.Merge should invoke virtual Table.Clone for copied tables.


I’ve posted this as a suggestion to Microsoft.
 


 

After Merge of Typed Dataset access to row fields causes System.ArgumentException


I am using typed dataset(generated by VS 2005) that I merged to empty dataset (actually to class, derived from dataset).


When I am accessed a particular row and tried to read value of the row field, I’ve got 


System.ArgumentException: Column <ColumnName> does not belong to table <TableName>. at System.Data.DataRow.CheckColumn(DataColumn column)


After debugging and digging into Designer generated code, I found that the cause is that
the generated typed-safe columns have property Table as null, when it is exspected to be a reference to owner table.


The fix was unexpectedely easy.


For merged tables it is required to call InitVars() method of generated Table class.
The Table
InitVars() looks like the following
internal void InitVars() {
//For each  table column

this.columnRetrieved = base.Columns[“Retrieved”];
}
The function InitVars()  is called in Table constructor and Clone, but is not called during Merge.
It as not a bug, but it should be considered when merge typed datasets into untyped one.



 

Different MarcXml to DC XSLT stylesheets.

I’ve compared a few available XSLT stylesheets from standards/marcxml/xslt .
As it noted in A Repository of Metadata Crosswalks,  the transformation from MARC XML to Unqualified Dublin Core 1.1 is realized in three encodings, requiring three separate XSLT scripts: as OAI DC(MARC21slim2OAIDC.xsl) , as SRW DC(MARC21slim2SRWDC.xsl ) , and as RDF DC(MARC21slim2RDFDC.xsl).
I’ve noted that YAZ Proxy download has slightly different (and seems older) versions of the similar stylesheets.



The most notable difference is that  MARC21slim2SRWDC.xsl output doesn’t include namespaces,e.g shows <title> instead of <dc:title>. 


Also seems that MARC21slim2SRWDC.xsl has more updates and produce nicer output, e.g. uses normalize-space Function.  


 

Multiple SCOPE folders in WEBDAV folder queries.

I am using WebDAV queries against Exchange Public queries. Because MAPI folders do not support deep traverse, I’ve used Multiple Folders as it is shown in MSDN :


SELECT “DAV:displayname”
FROM SCOPE(‘shallow traversal of “http://myserver/public”‘,
           ‘shallow traversal of “http://myserver/public/userinfo”‘,
           ‘shallow traversal of “http://myserver/public/userinfo/phonenumber”‘)


And I beleive that it worked against Exchange 2000 (I couldn’t confirm it, because I have now only Excahge 2003 available).


But against Excahge 2003 default(AKA MAPI) Public Folders the query returns not user-friendly


System.Net.WebException: The remote server returned an error: (501) Not Implemented.
   at System.Net.HttpWebRequest.GetResponse()


And after second reading I noticed that it is documented:
Note  Searching multiple folders by specifying multiple scopes in the query is not supported on a MAPI enabled public store.