Missing .NET Performance Counters: how to solve it
Today I’ve started to profile my applications to try to see if I have some memory leaks and performances bottlenecks.
I just started the inspection trying to look at some performance counters (especially to check if the memory allocated by my application kept growing)... but I had the surprise of the day when I couldn0t find any .Net related performance counter on my system.
At first I tried everything I knew to unload and reload performance counters, with the usual commands:
unlodctr .NETFramework
WSS / SharePoint : filter Users with the PeopleEditor control
Given the ListViewWebPart with advanced filtering capabilities we wrote in the previous articles, we want to extend it again and provide the ability to select which user (or users) we will use to filter our data out.
We can just write a simple web part that wraps the standard PeopleEditor control that comes with WSS or SharePoint.
The code is pretty straightforward, the PeopleEditor will be created and added to the Controls collection of the web part in the CreateChildControls() function. We will parse the data that the control exposes in the ITransformableFilterValues.ParameterValues property: each valid selected user will be contained in the PeopleEditor.ResolvedEntities collection (which contains PickerEntity objects).
The full code is listed below:
[Guid("4fddd9c3-37bf-48b9-84a2-0b4d96f98f92")]
svchost.exe (LocalSystemNetworkRestricted) 100% Hard Disk usage
Today on of my Vista developing workstations suddenly became very slow, the CPU was almost free and its usage was around 3-5%, the Hard Drive instead was overloaded with work, with its activity at 100% all the time. Trying to do any operation on the system requested ages..like 1 or 2 min to open the start menu or display a window.
Restating the system didn’t helped much, so I started to investigate the problem; opening the task manager and then the resource monitor I found out that I have many processes called like svchost.exe (LocalSystemNetworkRestricted) that were reading every files on the system (even the file related to the games I play at night).
So I opened the services management console to find something that could be run using svchost, I looked at every service there and found out that the ‘SuperFetch’ service (‘Ottimizzazione avvio’ in my Italian OS) was launched with this command: svchost.exe -k LocalSystemNetworkRestricted.
I disabled the service and rebooted the machine (I had to perform an hard reset cause the system was still hung reading the files on the disk). After the restart the problem disappeared and the system is back to be responsive.
In the end, it must be a bug of some sort related to the SuperFetch service, cause it ran fine for months without causing any problem.
WSS / SharePoint: adding filtering capabilities to the CustomListViewWebPart (Current User Filter and others)
Two of the biggest limitation of the standard ListViewWebPart is that it’s unable to filter the data using more than one single data provider and that it cannot use multiple values if the provider is capable of providing them (only the first value will be used). This is by design and you cannot avoid it in any way.
To solve both these problems we can take the code we already wrote for our CustomListViewWebPart (see: WSS/SharePoint: Create a Custom ListViewWebPart) and modify it a bit to add the following features:
- The support for multiple data providers (using the standard SP selection dialog to wire-up the fields with the provider values).
- The support for multiple values from a single provider.
- The <where> cause of the filter will be an <or> concatenation of all the values from a single provider, and will be an <and> concatenation of the different providers filter; a pretty standard way to filter the data from a table.
Most of the code is very similar to the previous version, so I will not go through it; let’s see the key points:
Multiple Providers Support
To make this Web Part able to connect to more than one provider, using the standard interfaces provided by SharePoint, we need to create a method with the signature: public void methodname(IFilterValues filterValues) and marked with then ConnectionConsumer attribute that specifies AllowMultipleConnections=true.
Inside that method we call the IFilterValues.SetConsumerParameters function that - given a collection of ConsumerParameter object (that specify the name and the capabilities of the parameters) - displays the standard SharePoint interface that allows you to choose to which field wire-up the provider.
To allow you to filter on all the fields of the list we will build the parameters starting from the list you are displaying through the instance of the Web Part. Here’s the code snippet:
[ConnectionConsumer("Filters", "FiltersForConsumer", AllowsMultipleConnections=true)]
WSS/SharePoint: create a Current User Filter Web Part
In MOSS we can filter some data on the currently logged User using the ‘Current User Filter Web Part’, unfortunately it’s not available in WSS. However building a simple Web Part that retriever the current user and that can be employed as a connection provider for other Web Parts isn’t that difficult.
To create a Web Part that act a data provider using the standard WSS/SharePoint infrastructure all you have to do is to implement the ITransformableFilterValues interface. You can then specify if your Web Part will provide single or multiple values for the parameter it will expose, if it can support an empty value and so on.
Accessing the currently logged user is extremely simple, actually it’s just a single line of code:
SPUser user = SPContext.Current.Web.CurrentUser;
VSeWSS: Unable to start debugging.The web server is not configured correctly
If you ever tried to debug a SharePoint WebPart project created with VSeWSS, you might have faced this problem, and like me you might have lost a lot of time trying to check the IIS configuration following one of the many guides you can find around.
Here are some links:
http://msdn.microsoft.com/en-us/library/aa290100%28VS.71%29.aspx
http://msdn.microsoft.com/en-us/library/0y3b8byc.aspx
The error reported is quite misleading and the solution was extremely simple (and stupid): before following all the steps reported in the guides, check the web.config of the WSS/SharePoint site you are trying to debug and change the ‘debug=”false”’ line to ‘debug=”true”’; here’s how it should look like:
<compilation batch="false" debug="true">