Tuesday, January 22, 2008

web.config appsettings and updates

Well, I finally figured it out. If you're like me, you have some settings in your website that you want to be able to update, but you don't want to bounce the app domain, yet, your values need to be displayed as changes.

I figured out how to do it. First, give the section of your web.config a config source. This will point your web.config to a separate file that you can use to store your settings. Since, it's this other file that is updating, your app domain shouldn't bounce every time you change a setting



Once you've added that line,

then add either in a separate class, partial, or wherever the following:

private void SaveSetting(string SettingName, string SettingValue)
{
//connect to the webconfiguration file
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");

//get the setting that you want to update
KeyValueConfigurationElement setting = config.AppSettings.Settings[SettingName];

//assign the new value to the setting
setting.Value = SettingValue;

//save the configuration changes
config.Save(ConfigurationSaveMode.Minimal, false);

// Force a reload of the changed section.
ConfigurationManager.RefreshSection("appSettings");

}



This will get the key that you are looking for, update it. You can actually see when this happens, if in Visual Studio you have the file open. It will prompt you that a change has been made to the file, and ask if you wish to reload it.

Edit: Note, that even when you force the RefreshSection, from what I understand, that'll only refresh the web.config section to reload. Appearently, it won't always refresh external files. So your changes may not show up right away. ARG.

If anyone has a solution to this, I'd appreciate it.

Thursday, January 17, 2008

.net framework debugging

It's finally out. On ScottGu's blog, he posted information on how to read the .net framework source code!

.NET Framework Library Source Code now available

You do still have to enable it, but at least it's available.

Free Microsoft books.

I just found 3 free microsoft books that you can download as a PDF:

Microsoft Press

Once signed in, you can download Introducing LINQ, Introducing ASP.NET AJAX, and Introducing Silverlight 1.0

You can preview a couple of chapters, or download the whole book in PDF format.

Enjoy!

Friday, January 11, 2008

SSIS, AS400 and the System.Byte[]

So, I have an SSIS package that I'm wanting to create. When I use the ODBC connection (similar in the DTS), I can pull everything over fine. I have 2 fields, one is a Char(3) the other a Char(13) on the 400. I've made the exact table in my sql server db.

The problem is that if I use the ole for .net instead of odbc, I get the following Error when I switch the provider in the SSIS package:




I'm using the IBMDA400 OLEdb\IBM DB2 UDB for iSeries when I get the error

I'm not having this problem with any other of my SSIS packages... wierd.