Search This Blog

Thursday, February 19, 2009

"The entry 'ConnectionString1' has already been added" error

I have a fairly involved web application working on my development laptop but when I push it to the client's IIS server I get a perplexing message from IIS when it tried to open a page that made a call to SQL Server -- it claimed that "The entry 'ConnectionString1' has already been added" in the Web.Config file.

An examination of the web.config file showed a single entry for ConnectionString1, no double entries anywhere, so I began walking through the code on the development server line by line in the debugger. No problems.

I went back to the client's server, completely cleared out my code, and then republished it. Got the same error.

A simple file search of the INETPUB directory showed an old WEB.CONFIG file in the root directory, one I'd actually put there months earlier when testing something and neglected to remove. Sure enough, there was the "second" entry for the connection string in there ... I simply deleted the old WEB.CONFIG file in the web root directory and it started working fine.

Another lesson in how important it is to clean up after yourself.

Wednesday, February 18, 2009

Tortoise/SVN ignore patterns for Windows development


I've used a variety of ignore patterns for doing C# Windows development in Visual Studio 2005/2008 and this one(from http://www.mokesit.com/Blogs/tabid/89/EntryID/18/Default.aspx) seems to work best, at least for now.

The pattern is:

*.cache bin obj *.suo *.obj *.pdb *.exe *.dll *.csproj.user

Note also that I use "_svn" directories rather than the default ".svn" just because it works so much better with the Microsoft OS.

Saturday, February 7, 2009

Getting Juice 2.2 Podcatcher to work in Windows 7

There are only two problems with getting the default install of Juice 2.2 (http://juicereceiver.sourceforge.net/) to work under Windows 7: the .EXE file needs to be set to run in "XP SP2 compatibility mode" and they've changed the directory name "My Documents" to "Documents" in the operating system so you need to modify the "IPODDER.CFG" file to reflect this.

Install Juice 2.2 as usual.

Go down into C:\Program Files\Juice and right-click on the JUICE.EXE file. In the properties window, click on "Compatability" and select "Windows XP (Service Pack 2)" compatibility mode.

Go down into C:\USERS\\AppData\Roaming\iPodder\ and open the file IPODDER.CFG. Change the text in the line beginning with "download_dir=" from "My Documents" to "Documents."

Close everything and restart Juice -- it should run as it did under XP or W2003.

Wednesday, February 4, 2009

Using curly braces in the .NET string.format command

I'm writing a C# application which accepts, parses, and passes PowerShell commands to an internal runtime instance of PowerShell.

The preferred method for string formatting with .NET is using the "string.format" method but I quickly ran into problems with the curly brackets used both by string.format (for placeholders) and PowerShell (for loop constructs).

For instance, this command will compile but will clearly screw up:

  • results = shl.RunspaceInvoke(string.Format(@"get-mailbox -identity {0} | %{$_.AcceptMessagesOnlyFromDLMembers | %{$_.DistinguishedName}}", Input1), out IErrors);

My first impulse was to remove the "@" from the string literal and escape the curly brackets but that looked simply dreadful and was too hard to debug -- the next solution which I tried, which worked was to simply double the curly brackets for anything other than string.format placeholders:

  • results = shl.RunspaceInvoke(string.Format(@"get-mailbox -identity {0} | %{{$_.AcceptMessagesOnlyFromDLMembers | %{{$_.DistinguishedName}}}}", Input1), out IErrors);

This is significantly easier to read and debug.