“Find was stopped in progress” in Visual Studio 2010

Visual Studio 2010 doesn’t search more than a few files and bails with the message Find was stopped in progress. This was driving me nuts, so I went to the web for an answer.

It turns out the way to solve this issue is to simply hit CTRL+BREAK a few times in the find window.

How do you fix the "Find was stopped in progress" issue in VS 2010? CTRL+BREAK

Looks like VS gets into a state that needs you to explicitly break it out of.

Happy Coding!

WPF IValueConverter Culture isn’t what you expect

I came across a defect that our DateTime IValueConverter wasn’t showing the local users regional settings.

I set a breakpoint into the converter and looked at the culture variable being passed in. The ShortDateFormat was "M/d/yyyy".

Well, my regional was set to "dd-MMMM-yy"

What gives?

I checked CultureInfo.CurrentUICulture. It had the right format string.

I attempted the language override fix:

[csharp]
  //Defaulting WPF to use at least the current cultures default values. Converters will still not use the local UI culture by default...
                FrameworkElement.LanguageProperty.OverrideMetadata(
                        typeof(FrameworkElement),
                        new FrameworkPropertyMetadata(
                        System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag)));
[/csharp]

Didn’t help with my scenario at all.

So, in the end, I just used CultureInfo.CurrentUICulture to format the string. A bit annoying.

[csharp]
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return NoDateString;
            var d = value as DateTime?;

            if (d.HasValue) return d.Value.ToString(parameter.ToString(),System.Globalization.CultureInfo.CurrentUICulture);
            return value.ToString();
        }
[/csharp]

If you find a better way, please feel to drop me a note.

Happy coding!

Perforator doesn’t allow me to attach to any processes

Are you using the WPF Perforator in the WPF Performance suite and wondering why the process attach dialog has everything greyed out and disabled?

So did I. It drove me nuts, until I found out one key thing. Apparently, Perforator can only attach to processes that were started AFTER the Perforator tool was.

Gee…Wouldn’t that have been a nice thing to show in the dialog as a hint? Apparently, no one writing that tool thought about the UX in that scenario. Showing them greyed out, brilliant.  A tooltip, message, anything that said "This process can not be attached to because it was started before Perforator" would have saved serious time.

Hopefully this little nugget will save you time as well.

So, how do you attach Perforator to a running process? Start Perforator first,start your process next, then attach. Simple, yes. Intuitive, no.

Of course, you are coding in WPF. Did you expect anything to make sense?

Happy Coding!

Windows Live Mesh–Piece of Crap

I thought the Live Mesh was a decent product, slow but decent. That is, until I decided to disconnect a display while I was using it. My thought, it would speed up transfer since I have three monitors, that is a  lot of data.

Well, it worked fine while I was remote. I got into the office, went to turn my computer on and all I saw on my primary monitor was a mouse cursor. The display would not show anything but a black screen with a cursor. I rebooted 4 times, no avail. Disconnected (physically) that monitor and the others had the same issue, all black, just a cursor.

I ended up remoting in from another machine, which still worked fine, and had to uninstall live mesh. This of course after trying a bunch of things, such as reenabling the monitor I disabled etc.

Long story short, Live Mesh can cost you hours in frustration and lock you out of your own computer.

That lands it in the Piece of Crap category.

Detect Windows/Operating System Version in C# .NET

Are you looking for a way to detect which OS you are running on in your .NET application? I know I had to so that I could implement workarounds that were OS specific.

Here is a simple function to get the name. You can use this as an idea of how to pick the exact version you are on.

Please don’t be one of those morons that uses this function then does a string comparison on the return. Use common sense and extract the logic from this to get what you need.

I better not see any code out there like

if(GetOSVersionName() == "Windows 98"){Do stupid stuff here}

Yes, it would technically work, so I have no doubt it will be implemented that way by some of you. Religious debate? Probably.

[csharp]
 public string GetOSVersionName()
        {
            string strVersion = "Unknown";
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32S:
                    return "Windows 3.1";
                case PlatformID.Win32Windows:
                    switch (Environment.OSVersion.Version.Minor)
                    {
                        case 0:
                            return "Windows 95";
                        case 10:
                            if (Environment.OSVersion.Version.Revision.ToString() == "2222A")
                            {
                                return "Windows 98 Second Edition";
                            }
                            else
                                return "Windows 98";
                        case 90:
                            return "Windows ME";
                    }
                    break;
                case PlatformID.Win32NT:
                    switch (Environment.OSVersion.Version.Major)
                    {
                        case 3:
                            return "Windows NT 3.51";
                        case 4:
                            return "Windows NT 4.0";
                        case 5:
                            switch (Environment.OSVersion.Version.Minor)
                            {
                                case 0:
                                    return "Windows 2000";
                                case 1:
                                    return "Windows XP";
                                case 2:
                                    return "Windows 2003";
                            }
                            break;
                        case 6:
                            switch (Environment.OSVersion.Version.Minor)
                            {
                                case 0:
                                    return "Windows Vista";
                                case 1:
                                    return "Windows 2008";
                                case 2:
                                    return "Windows 7";
                            }
                            break;
                    }
                    break;
                case PlatformID.WinCE:
                    return "Windows CE";
                case PlatformID.Unix:
                    return "Unix";
            }
            return strVersion;
        }
[/csharp]

Happy Coding!