Tuesday, May 01, 2007

Reading appSettings from BTSNTsvc.exe.config in Vista

I am not getting into all of the discussions on what's the best way to store and retrieve information at run time when running Biztalk 2006. For small things, I like to use the BTSNTsvc.exe.config file.

For Windows 2003 you will open the file and add the keys you need, i.e:

<add key="xxx.newYear" value="2009"/>

<add key="xxx.newXSN" value="http://site.com/template.xsn"/>
Then inside your orchestration you can have code like this inside your expression/message assignment shape:

sXSNPath = System.Configuration.ConfigurationSettings.AppSettings.Get("xxx.newXSN");
sYear = System.Configuration.ConfigurationSettings.AppSettings.Get("xxx.newYear");

and you can test the values by writting them out:

System.Diagnostics.Trace.WriteLine("bts- XSD:[" + sNewXSNPath + "]");
System.Diagnostics.Trace.WriteLine("bts- Year:[" + sYear + "]");

However, if you are running Vista, these calls return blanks.

The reason for this is the new feature of Vista called Virtual Stores. What this functionality is that it allows your running program to save information into one of the secured folders (Program Files). When in fact, it is creating a virtual location for you. In my case, the actual location of the BTSNTsvc.exe.config file that Biztalk is looking for is located at:

C:\Users\awing\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Biztalk Server 2006

and not in the

C:\Program Files(x86)\Microsoft Biztalk Server 2006 folder.

This could get confusing for some users, since there is no errors or warnings about it. I can see how some applications could get out of sync really quick.

For instance if you have the UAC turn on, and have been using a software that stores its data on the c:\program files\Cust_App\. Then after a couple of weeks/months, you decide to turn off the UAC, you will find, that your application will have missing data.!

No comments: