How to check if process is not responding?

There is no general solution to this problem. It is impossible to tell if a particular process is hanging or not, because the term “hanging” is entirely dependent upon the context of the process that is executing. The hanging process will always do what it was coded to do. The developer may have coded it … Read more

How do I install and use the ASP.NET AJAX Control Toolkit in my .NET 3.5 web applications?

Install the ASP.NET AJAX Control Toolkit Download the ZIP file AjaxControlToolkit-Framework3.5SP1-DllOnly.zip from the ASP.NET AJAX Control Toolkit Releases page of the CodePlex web site. Copy the contents of this zip file directly into the bin directory of your web site. Update web.config Put this in your web.config under the <controls> section: <?xml version=”1.0″?> <configuration> … … Read more

How to convert Func to Predicate?

Easy: Func<string,bool> func = x => x.Length > 5; Predicate<string> predicate = new Predicate<string>(func); Basically you can create a new delegate instance with any compatible existing instance. This also supports variance (co- and contra-): Action<object> actOnObject = x => Console.WriteLine(x); Action<string> actOnString = new Action<string>(actOnObject); Func<string> returnsString = () => “hi”; Func<object> returnsObject = new … Read more

Does the .Net Framework 4.0 Installer include the .Net Framework 3.5?

The .NET 4.0 installer doesn’t include the .NET framework 3.5. There is some information on this topic in MSDN: The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance. The .NET Framework … Read more

See if user is part of Active Directory group in C# + Asp.net

With 3.5 and System.DirectoryServices.AccountManagement this is a bit cleaner: public List<string> GetGroupNames(string userName) { var pc = new PrincipalContext(ContextType.Domain); var src = UserPrincipal.FindByIdentity(pc, userName).GetGroups(pc); var result = new List<string>(); src.ToList().ForEach(sr => result.Add(sr.SamAccountName)); return result; }

Get first element from a dictionary

Note that to call First here is actually to call a Linq extension of IEnumerable, which is implemented by Dictionary<TKey,TValue>. But for a Dictionary, “first” doesn’t have a defined meaning. According to this answer, the last item added ends up being the “First” (in other words, it behaves like a Stack), but that is implementation … Read more

How do I group items in a WPF ListView

I notice one thing right away – the GroupStyle.HeaderTemplate will be applied to a CollectionViewGroup, so your DataTemplate should probably look like this: <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <TextBlock FontSize=”15″ FontWeight=”Bold” Text=”{Binding Name}”/> </DataTemplate> </GroupStyle.HeaderTemplate> </GroupStyle> CollectionViewGroup.Name will be assigned the value of Status for that group.

WPF modeless dialog from MS Excel add-in

Solved it, courtesy of this link: Running WPF Application with Multiple UI Threads var thread = new Thread(() => { var wpfWindow = new WPFWindow(); wpfWindow.Show(); wpfWindow.Closed += (sender2, e2) => wpfWindow.Dispatcher.InvokeShutdown(); Dispatcher.Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start();