Powershell: How to display all loaded assemblies on your system and which process they belong to

Have you ever wondered what processes on your machine are using a particular assembly?
Ever deployed an update to an assembly, and wondered which processes needed to be restarted?

Thanks to powershell goodness, we can do this quite easily – I threw this function together for you to use. It’s not the greatest piece of powershell, but it does the job.

function GetAllLoadedAssembliesFromProcesses([string] $filter)
Write-Host “Listing all assemblies loaded with filter: $filter, and which process it belongs to…”
get-process | Foreach-Object { $processname = $_.ProcessName
$ErrorActionPreference = “Stop”
$mods = $_ | select -expand modules
$mods | foreach-object { if($_.FileName.ToString().Contains($filter)) { Write-Host $processname, $_.FileName } }
}catch { Write-Host “Cannot access $processname” }
finally { $ErrorActionPreference = “Continue” }


Microsoft.SharePoint.SPException: One or more field types are not installed properly. Go to the list settings page to delete these fields

If you’ve been around the traps long enough in the SharePoint world like we have, you would almost undoubtedly come across this exception.

I wanted to share with you what the most common cause of this exception is, it’s very deceptive and not usually the most obvious thing at the time.

This exception usually raises its head when you are performing a CAML query against a SharePoint list.  You might first think that it’s due to the fact that the list you are querying has some misconfigured columns – it might very well have.  But I’m not here to discuss with you those edge cases – I want to give you the most common reason.  Take this query:

 SPQuery query = new Microsoft.SharePoint.SPQuery();
                query.Query = string.Format("<Where><Eq><FieldRef Name='{0}'/><Value Type='Text'>{1}</Value></Eq></Where>", fieldName, properties.ListItemId.ToString());
                SPListItemCollection listItems = list.GetItems(query);

If the list you have deployed does not have a column defined by “fieldName”, you will receive this exception.  For instance, if your querying a list with a column called “TaskId”, and your list does not have a column defined as “TaskId”, or if it does, and it’s type doesn’t match that of what you are selecting in your CAML (ie, Value Type=’X’ – if X doesn’t match your column type) then you will get this exception.

Simply make sure you have the column defined, by going into your list settings, and check it’s type and ensure you are selecting the correct type in your CAML.  This can happen for all types of reasons, but generally a lot of the time it turns out to be a versioning problem – or you have not deployed your list definition (or you have done so, incorrectly, causing the column not to exist, or it’s type to be mismatched).

Deceiving, isn’t it?  Maybe one day we will see better error messages!

Download FSEXTEND.EXE (Disk Part)

You can download it here: http://goo.gl/glScd

Thanks to this man: http://www.edwardsd.co.uk/work/blog/2010/05/14/fsextend-exe-diskpart/


Extending a Server 2003 VMDisk with VMWare workstation and diskpart

I took a copy of a VM hosted in VMWare server, installed VMWare workstation locally, then extended the virtual machine’s VMDisk.

That’s all well and good, but you still need to extend the NTFS file system inside the VM, VMWare will not do this for you (fair enough!).

So, I copied the VM, then attached the original VM to the copy as a secondary disk. I booted into the VM, and opened disk manager in windows (start -> run -> mmc -> add snapin -> disk management). You will see the secondary drive with the free unallocated space. Unfortunately, you can’t just simply extend this partition with diskpart, because there’s a bug which will cause it to fail in this exact scenario.

If you try and extend using diskpart, it will sit there and never complete, however in disk management you will notice that it seems as though it has extended it. What it has done, is gotten half way through, and the first part of the operation is to extend the partition (the part which makes it look like it has been extended in disk management), but it hasn’t really extended the file system. You’ll notice in explorer that the drive is still using the same amount of disk.

The fix is extremely simple, head over here: http://www.edwardsd.co.uk/work/blog/2010/05/14/fsextend-exe-diskpart/
Download FSEXTEND.EXE – yes, the infamous tool – which can be found on Edward’s blog (thanks a million!!). Run up a command prompt, and make sure you’re on c:\, then type fsextend.exe e: (where e: is your secondary drive).

You’ll notice in explorer that your disk is now correctly extended.

JQuery Hack: Contracting all Excel Web Services web parts to their maximum height

IF you’ve ever used excel services, and particularly – their integration with SharePoint 2010 via web parts, you’ll notice that it always creates a big chunk of white-space in the web parts. It seems to add an inline style of 400px height (or other, depending on the excel file sizing, etc).

What we really want, is a generic way of contracting those web parts regardless of how the excel files have been configured by end users.

Well, the way I had to do it (and very quickly, due to our great time requirements :(), was through a JQuery hack:
I don’t usually post these hacks, as there’s generally always a better way of doing things, but I hope this might help someone else out there, even if it is a temporary fix. It also doesn’t take into account the interchanging between the different unit types (px,pt), etc.

$(document).ready(function() {
$(“div[id*=’WebPartWPQ’]”).filter(function() { return $(this).find(“div[id*=’Excel’]”).length > 0; }).each(function() { var origHeight = $(this).height(); var maxHeight = Math.max.apply(null, $(this).find(“*”).children().map(function (){ var item = $(this).height(); if(item maxHeight) { $(this).css(‘height’, maxHeight + ‘px’); } }); $(this).attr(‘style’,”); } );

Happy hacking.

Closing SharePoint 2010 wait dialog with JavaScript

There’s one nice feature of the SharePoint 2010 UI framework which lets you display a wait dialog with no close button:

SP.UI.ModalDialog.showWaitScreenWithNoClose('Please wait ...', 'Please wait while we process your request ...', 80, 400);

You may want to run this on client click of a button, which ultimately posts back the page.  In my case it was a dialog which did some processing, then ultimately closed.
If you call the above function, and the page posts back, when it returns the wait dialog will still be there… it won’t go away!

Okay, so you say – it should be as simple as calling window.frameworkElement.commitPopup(); … negative, this does NOT work for the above dialog (because likely when you’re executing this, you’re executing it on the main window, not the wait dialog’s frame, which renders this call useless.. and in most cases if you have other SPDialog’s open, it will close THEM, but not the wait dialog.

ANYHOW… JQuery to the rescue: Here’s the fix…
Simply hook a document.ready on the page which is posting back, and manually hide the Dialog and overlay, by doing the following:

$(document).ready(function () {
    ExecuteOrDelayUntilScriptLoaded(function () {
       // UPDATE: Original post I had this executing in the current frame, I change this now to execute on the top frame, otherwise it can't find the dialog
        if (($(top.window.document).find('.ms-dlgContent')).length > 1) {
            $(($(top.window.document).find('.ms-dlgOverlay'))).css('display', 'none');
        }}, "sp.js");
    // Demand the loading of the SP.js script (demand ribbon, which cascades into sp.js and a few other required items such as sp.dialog.js)
    SP.SOD.executeFunc('ribbon', null, function () {});

This will search for all spinner images within the currently open dialogs, and return the last element found (which is generally always the top level dialog – the wait dialog.). It then searches upward for the closest dialog frame, then hides it with a bit of CSS magic. You could probably search upward for the frame element and perhaps close it, but this suited what I needed to do perfectly, because the page will post back soon enough and it will be gone anyway.

jQuery document ready not firing with ajax update panels

The scenario is:

1. You’ve got an update on a page, and you have some jQuery executing a document.ready event.
2. The event isn’t firing when your update panel posts back asynchronously.

The solution is quite easy, take your original document.ready script and wrap it in a function and place it outside of your update panel (linked js file is fine):
function BindLoadEvents() { $(document).ready(function() { alert(‘fired!’); }); }

The bold text was the body of your original function.

Now, inside your update panel (preferably at the top):
<script type=”text/javascript”> if(typeof BindLoadEvents == ‘function’) Sys.Application.add_load(BindLoadEvents); </script>

Now, your script will execute when ajax has finished loading the page, including when new postbacks are made within your update panel!

Note that I have noticed slight flickering on the first request, to get around this, you can inline a call to BindLoadEvents(); within your <script> which sits outside of the update panel (below the BindLoadEvents function def), this will cause it to execute twice though, but the first time will be executed as the page renders, vs waiting for the page to finish loading, hence removing the slight delay.).  Let me know if there’s a nicer way to fix this glitch.


Feature could not be installed because the loading of event receiver assembly X failed:

The problem is, when you’re in visual studio debugging a feature receiver, and you have your build actions set to ‘Default’ (ie, not No-Activation), it will deploy the solution, then try and activate your feature (which has your event receiver in it (which probably deploys an SPTimerJob or something similar)).  You get the error saying that it cant find your assembly.  BS!  It’s in the GAC!  I can see it, and it’s the right version??

I’ve just been banging my head against the brick wall with this one.
I came across the following article.

But unfortunately it didn’t help me out, the comment someone left in there about using -force was interesting, but I need this to work within VS… if I just use powershell, it activates fine.

The quick and (maybe a little bit dirty) solution for me (without needing to create and move a bucket load of code into a new project), is simple:  Bump the version number on the assembly that contains your event receiver (read: the assembly you’re deploying to the GAC).  Go into the assemblyInfo manifest, and update the version from to, then redeploy.  Violla… the problem will go away (or at least, it did for me).

Second to this, you’ll notice then that all references to the Strong Name of that assembly then need to be updated.  If you’re referencing it in user controls and so forth, take a look at replacing the Version= component of the strong name with: Version=$SharePoint.Project.AssemblyVersion$

The sharepoint project system in VS will replace this macro with the current assembly version, saving you having to update it each time when you change it (when you get this error, for instance :)).

All web part pages will need to be updated as well, (ie web parts need to be reimported, because the version changed).  Do it once, and you shouldn’t see it again (not sure what originally caused it… but for me, it was after a reboot! Random.).


Earlier this week I found myself delving deep into the realms of timer jobs, and found that the SharePoint Timer Service loves to cache assemblies (Objects table in sp config).  I received this same error today.  Using my knew found knowledge as a premise, I retracted my solution in VS, I then restarted the SPTimerV4 service,  then redeployed the solution – the features now activate.  I think the reason it can’t find the assembly is something to do with it using an older cached version of the assembly, and because (correct me if I’m wrong) that feature activation is run through the timer service, this some how relates to it not being able to find the assembly.


How to install Windows 8 side by side with Windows 7 the easy way!!

I have been trying many different ways to get windows 8 installed… I have been trying to find the least ‘intrusive’ way that I can.

I just wrote an entire write up on how to do this.  But wordpress deleted it.  Thanks word press for wasting an hour of my time, and hard work.

In order to do this, simply read this.

If you want to boot from a VHD on an external hard drive, read this.

Thanks again, WP.













Windows 8

So if you’re been living under a rock for the last day or so (OK, fair enough, this is pretty fresh news, I don’t blame you).  Then you’d know that Windows 8 Developer Preview has been released!
I thought I would take this opportunity to share with you some of the content that I’ve reviewed and gathered with regards to Windows 8, to save you a bit of time trawling through the interwebs.

Before I continue though, you’re probably wondering where to get it:

There’s 3 skews you can download:

1. Windows Developer Preview with Developer Tools (English), x64
2. Windows Developer Preview English, 64-bit (x64)
3. Windows Developer Preview English, 32-bit (x86)

The main difference between the 2 types here (tools/no tools), is that the first on the list contains all of the tools (SDKS, etc) to develop on the new Windows 2008 platform, you also can’t perform an in-place upgrade of your pre-existing operating system using this version, in order to do an upgrade you need to use the last 2 in the list (not that I would suggest doing this on your favorite box just yet!).

Interesting Resources / Videos:

1. Build hardware overview video
2.  Windows Developer Preview Technologies
3.  BUILD Keynote
4. Walkthrough of the new Windows 8 User Interface
5. Smarter file copying in Windows 8
6. Mango apps now being accepted on the Market Place!

If you have any other cool links, please feel free to share them and I’ll add them to the list!
I’ll keep adding them as I come across them.