WordPress Plugin Updates Fails in IIS 7. Locks folder after delete and requires an IIS restart to release file locks

I was trying to update the plugins on my WordPress blog today, and it failed….again and again…and again. I was used to the auto update not working. So much so, I always backup my plugins folder, try and then replace the old version and carry on.
Well today, I was fed up and wanted to get everything up to date.

I changed filed permissions, I restarted IIS beforehand, I even tried using Jedi mind powers. It was all fruitless.

I finally was able to follow a nugget of information that led me to a bright person somewhere who said it was due to PHP caching. Well, since I don’t know very much about PHP (open source legacy wannabe script language), I figured, of course it was. I like to blame PHP, or anything that isn’t my own code for that matter.

The WinCache in PHP decides it likes the plugin folders a whole lot. So much so, it will never let them go. Until now, the fine fellows that designed the cache fixed their glitch.


Good luck and Happy Coding!

Initialize a static Dictionary inline in the declaration

Have you ever wanted to initialize a Dictionary object with lookup values, but didn’t want to put the code into a static constructor?

Well, here is the easy way to do it. Quite easy actually, just like declaring an Arrays initial values.

I decided I want to create a simple lookup dictionary keyed off of a string with the value being an int. Basically, I have strings that need to be matched to ints, for a custom sort algorithm with discrete inputs.


//discrete mapping dictionary
//initialized with the 4 values below
public static Dictionary<string,int> sortValueLookupDictionary = new Dictionary<string,int>()
 {"Key 1",1},


Happy Coding!

Zyngas free “gift” for Scramble with friends players: Pile of crap

I got an email from Zynga yesterday announcing gifts to the players of their games. I figured, maybe a free ad free, or an allotment of tokens. Something of some value to their user base.

Well, it turns out, at least based on the ad in-game, that the "gift" is a free second power up. That, in and of itself, would be great if it was permanent. According to the ad though, it will only be for today.

So, I think their "gift" is a pile of crap. A lot of advertising for their appreciation for a temporary lifting of a "price" for using the second power up in their game. A lifting for one day?

A gift is something you get to keep. I don’t see this as a gift. It’s just a bad marketing move by a large company that doesn’t value their customers.

Death by icon: Memory Leak in WPF Using MVVM and ImageSource

I was running a memory profile on our client application and kept seeing views being stuck in memory. It was odd since we freed them and there weren’t any discernable links that should be keeping them alive.

Well, that is until I saw that a GC Root object holding a reference at the top of the chain was an icon. An Icon. It was holding together a massive view and all the data, controls and containers that go with it. The memory would increase by 5-10 megs each time you went and left the view.

So, my next step was to figure out how in the world this icon was holding the view in memory. Where was the reference? The only usage was a simple binding to show the icon for particular types of nodes in our treeview.

I remembered from an earlier performance run that WPF has Freezable objects. WPF monitors these objects for changes. Well, that sounds like it uses an event. I doubt it polls.

I was right. There is an event on the image source. Apparently WPF latches on to that bad boy, and voila. You have a valid reference to the icon that the GC see as needed.

Why needed, well, to save cycles, we use a static instantiation of the bitmap. Loading from resources is expensive, so we use a readonly static. It never goes anywhere, therefore anything bound to its events doesn’t go anywhere.

So, what is the fix? I don’t want to stop using my static, as now I introduce a performance penalty. I can’t stop using the icon, then the user would be perturbed.

What to do?

Well, bring out your ice ray gun, because the solution is to Freeze the image. I mentioned earlier that WPF has Freezable objects. Well, if you Freeze it, then WPF doesn’t bind to the event since the object can’t change. So, a few lines of code later and we have a memory leak disaster averted.

Here was the old way:

private static readonly ImageSource MyIcon = new BitmapImage(new Uri("pack://application:,,,/Seekford.Client.Resources;component/Images/Icon.png")); 

Here is the new way:

   private static readonly ImageSource MyIcon;
        static MyTreeModel()
            MyIcon = new BitmapImage(new Uri("pack://application:,,,/Seekford.Client.Resources;component/Images/Icon.png"));        

Simple, right. Yeah, if you know what to look for in the first place Smile


Happy coding!

Visual Studio 2010 Crashes/Disappears when getting latest from source control(TFS)

We use Visual Studio 2010 with Team Foundation Server for our projects. It seems that when I get latest after there were a large number of changes, VS just disappears.

No event log entry. No crash report. Just the handy feature of auto closing after getting latest.

Bizarre and annoying.

If you have any ideas on why this is happening, that would be great. Otherwise, this is just a rant.

Note: I am sure have 127+ projects in our solution doesn’t help with stability.

Happy Coding!