Windows 8, Hyper-V, BitLocker and “Cannot connect to virtual machine configuration storage”

So I am now working at a new professional services company in South East England (Ballard Chalmers) who use Hyper-V throughout their DEV / TEST environments. I have previously been a VMWare Workstation person myself (and I still think the simplicity and ease of the user interface is unmatched) but for the foreseeable time I will be running Windows 8.1 Pro on my laptop as a Hyper-V host.

Before we get started it is worth describing my setup:

  • Windows 8.1 Pro
  • 3rd Gen Intel i7-3820QM CPU
  • 32GB DDR3 RAM
  • Two physical disk drives
    • C:\ SYSTEM – 512GB SSD (for Operating System, Files and Applications)
    • D:\ DATA – 512GB SSD (for Hyper-V Images and MSDN ISOs) (running in an “Ultra-Bay” where the Optical Drive used to be)

Now like most modern laptops I have a TPM (Trusted Platform Module) on my machine so I also have BitLocker encryption running on both my C: and D: drives (for those who are interested I barely notice any performance drop at all .. and I can still get 550 MB/s sustained read even with BitLocker enabled).

Saved-Critical – Cannot connect to virtual machine configuration storage

Now I noticed from time to time that my Virtual Machines were showing error messages when my computer started up. I noticed it here and there until Thomas Vochten (@ThomasVochten) also mentioned he was getting it every time he started his machine up.

Hyper-V Error

Note – You can get this error for all sorts of reasons, particularly if you have recently changed the Drive Letters, re-partitioned your hard disks or moved a VM. In this case I was getting the error without doing anything other than turning my laptop on!

Read more »

64GB of RAM in a Laptop, and why I want it …

Well, the rumour mills have been well and truly circulating recently about the potential for high capacity DRAM chips which could allow laptops to have up to 64GB of memory. I was recently directed to this article (http://www.anandtech.com/show/7742/im-intelligent-memory-to-release-16gb-unregistered-ddr3-modules) from the ArsTechnica forums.

This article basically describes a new method of DRAM stacking (as opposed to the standard method of NAND stacking) which allows the production of 16GB SODIMMs chips. My current laptop has four SODIMM slots (like pretty much every other high-end laptop on the market) so with the current maximum of 8GB SODIMMs my laptop supports 32GB RAM. If I could use 16GB SODIMMs then I could theoretically swap those chips out for a straight 4x 16GB SODIMMs (i.e. 64GB of RAM).

The best news is that these chips could be on the market this year!

“Mass production is set to begin in March and April, with initial pricing per 16GB module in the $320-$350 range for both DIMM and SO-DIMM, ECC being on the higher end of that range.” (source: Anandtech article linked above)

Read more »

Embedding Sandbox Web Parts into Page Layouts and Master Pages

Note – this is applicable to both SharePoint 2010 and SharePoint 2013 .. and despite rumours of “The Sandbox is deprecated” many features in SharePoint 2013 rely on the Sandbox so I don’t see it going anywhere for the time being

This is something that I have been told many times, it is not possible to embed a server control developed in the Sandbox onto a Page Layout or Master Page because you can’t add the appropriate Tag Prefix to the header.

If you consider the standard way of doing this for a Farm / Full Trust solution:

<% @Register TagPrefix="MJH" Namespace="MJH.Examples.WebControls" Assembly="MJH.Examples, Version=1.0.0.0, Culture=neutral, PublicKeyToken=16e05f568fffc0d1" %>

<!-- Custom Web Control-->
<MJH:SampleCustomControl runat="server" />

In the sandbox we obviously can’t reference the Assembly in the same way because (a) it isn’t deployed to the GAC / BIN folders and (b) it runs in a completely different process so won’t be JIT compiled by the .Net Framework… but there is a solution!

Microsoft.SharePoint.WebPartPages.SPUserCodeWebPart allows you to embed a Web Part from an assembly running in the Sandbox.

<!-- custom sandbox web part -->
<WebPartPages:SPUserCodeWebPart 
      runat="server" 
      AssemblyFullName="MJH.Examples.Sandbox, Version=1.0.0.0, Culture=neutral, PublicKeyToken=60d6fc7a560ae45c" 
     SolutionId="4faf8ff6-36ea-406f-af25-4d89472a41e1" 
     TypeFullName="MJH.Examples.Sandbox.WebParts.SampleCustomControl" >
</WebPartPages:SPUserCodeWebPart> 

You still need the “AssemblyFullName” attribute. I’ve found the easy way to get this is to add a feature receiver to a Feature in Visual Studio then copy-paste it from the Manifest in Visual Studio (which contains the full text that you need).

So thats it! Happy coding

Provisioning List Views in the onet.xml with custom Web Part properties

I’ve seen this come up numerous times (with a few people telling me “its not possible without writing code”) so I thought I’d chuck up a simple code sample showing you how this is done in SharePoint 2013.

Lets say you want to add some List View Web Parts to a custom Team Site for a Tasks list:

  • My Tasks
  • Tasks In Progress
  • Tasks Overdue

You would initially do this kind of thing in your onet.xml:

<View List="Lists/Tasks" BaseViewID="1" WebPartZoneID="Header" />
<View List="Lists/Tasks" BaseViewID="2" WebPartZoneID="Header" />
<View List="Lists/Tasks" BaseViewID="3" WebPartZoneID="Header" />

Of course the main problem here is that you have zero control over any of the Web Part properties (such as the Title, border, or anything else). The default title will use the same title as the list, which of course (when you have the same list more than once) offers the stunningly un-useful:

  • Tasks (1)
  • Tasks (2)
  • Tasks (3)

The solution is to include some additional Web Part properties in embedded CDATA tags:

<View List="Lists/Tasks" BaseViewID="1" WebPartZoneID="Header"> <![CDATA[

<webParts>
      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
              <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
              <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
              <properties>
                  <property name="Title">My Tasks</property>

              </properties>
          </data>
      </webPart>
</webParts>
]]> </View>

This gives you effectively complete control over any of the Web Part Properties (see XsltListViewWebPart Properties).

Happy coding!

Migrating from Blogger to WordPress

So I’ve got myself a shiny new blog design, and more than that it is running on both a shiny new hosting provider (Azure Web Sites) and a shiny new platform (WordPress). So this post is going to run through the reasoning behind why I moved, why I chose WordPress and (equally importantly) how I actually did it.

I can say that I am very pleased so far with the WordPress experience. It has been a relatively quick and painless experience and migrating all of my old content from Blogger.com to my new hosted WordPress site (including setting up the theme and a bunch of “widgets”) only took me a few hours (easily achievable in one evening). I am quite a fan of the interface although I admit the current style still requires a fair bit of polish here and there.

The main issues I’ve faced have been post formatting as the migration doesn’t appear to have brought over all of my images (although most of them appear to be intact). Also the formatting of code blocks appears to have stripped out what it obviously thought were harmful scripts (a lot of my JavaScript code samples have magically disappeared) so that will need some cleanup

Read more »

I’m Speaking at SharePoint Saturday UK 2013

I am honoured to have been invited back as one of the speakers of SharePoint Saturday UK.

This is a FREE annual event (so far held in the UK midlands) towards the end of the year and always includes a tonne of awesome content for developers, IT Pros and power users, and this year is no exception.

This year it will be held at the Hinckley Island Hotel, Hinckley, Leicestershire on the 9th November. As usual there are loads of great sessions and some really excellent seasoned speakers of international fame.

I’m will be speaking in the DEV track about Developing custom templates for the Content Search Web Part in SharePoint 2013, but definitely check out the full schedule and speaker list.

The event is always concluded with a SharePint and a good night out so if you are UK based (or fancy travelling over for the day) make sure you register for the event and hopefully I’ll see you there!

If you are avid on twitter then be sure to keep an eye on the #SPSUK hashtag for all the latest event updates.

MSDN Azure credits… its not for “you”, its for “us” …

So I recently found out about a great new set of offers that Microsoft are offering for all MSDN subscription owners called “Windows Azure Benefit for MSDN Subscribers“. You basically get free Azure credits every month and discounted pricing.

  • MSDN Ultimate – $150 per month
  • MSDN Premium – $100 per month
  • MSDN Professional – $50 per month

This is also combined with a 25% discount in the charge rate for each machine that you are running, and this is fantastic value.

For most SharePoint development and testing teams you will be looking at the top two, although much more expensive the Premium ($2.5k per year) and Ultimate ($4.2k per year) these are the MSDN subscriptions which include Office and SharePoint software for development and testing purposes (check out the MSDN Edition comparison for more details). There are other options out there but a lot of development teams will be using MSDN.

Equally if you are doing SharePoint development which in the Azure world will typically mean an “Extra Large” VM (8 Cores and 14GB RAM). This rolls in at $0.48 per hour of operation, and probably raises another major point … only 14GB RAM?

With Windows 8 Hyper-V (free) and VMWare workstation (around $100) and most contractors running insane dual-SSD 32GB laptops you gotta wonder, why would I want a 14GB VM in the cloud when I can run a 24GB VM locally? Also .. what happens if I am on a train / airport lounge / plane and can’t access the internet?

Well .. good point ..

$100 a month is great, but Azure VMs are very expensive!
Now, I know a few contractor friends of mine in the industry who have looked at this and decided that its not for them .. I am one of them (yes that is right .. I’m advocating a new service which I myself am not going to use).

But this is not really for the sole contractor, and certainly not someone who works all of gods hours (either doing research, writing books or blog posts and preparing for conferences and user groups).

Now this is where the average contractor gets off the Azure train. If you are very busy and put in a lot of extra hours it is not uncommon to run your VM for 12 hours a day plus some conference / user group work at weekends … this can quickly add up*

* note – I realise not everyone works these kinds of hours .. I personally don’t, I have a wife and baby daughter at home and generally work a 9-5 work day .. but I know some people work longer hours, and I sure put in extra time when prepping for conferences

5 days a week @ 12 hours per day, plus another 12 hours over the weekend = 72 hours per week
72 * $0.48 = $34.56 per week
$34.56 * 52 = $1,797 per year
$1,797 / 12 = $149.76 per month

So if you are rolling with MSDN Premium you are going to be out of pocket, and even if you are lucky enough to be an MVP (and have MSDN Ultimate) or just have deep pockets .. you are still scraping the barrel and probably watching the clock every week to make sure you don’t go over the limit.

“You” are not their target audience … “We” are ..
I suppose this really rounds to my core point .. this subscription model is not aimed at the individual developer or contractor. It is aimed at development teams. The place I’m currently at has 5 developers working in three different countries all running MSDN Premium. This gives them a combined allowance of $500 per month of Azure credits.

Being an office-based development team it pretty much runs off standard office hours. The development machines only need to be on for office hours (typically 8am – 6pm unless there is a major version launch coming up) and almost certainly don’t need to run at weekends. With a group of users you can also look at consolidating your infrastructure (why not run a shared SQL instance so you can drop your VM hardware?). Equally you probably don’t need to run all of the services all of the time on every development machine (if you aren’t building a search solution then turn it off!).

With $500 per month to spend they can run 5 XL VMs 9am-5pm every week for free (some weeks you won’t need to have all 5 machines running .. so turning them off when you aren’t using them can help to pay for those other times when you need to run them for longer!).

Even if you do use more horsepower than that .. try putting the figures in front of your IT Manager / Head of Infrastructure … You might be surprised how happy they are to pay for the “extra” over and above those free Azure credits (some months it might cost you an extra $100 or so .. some months you won’t have to pay anything … compare that to other hosting providers and see how much it would cost you!)

How about using it for testing?
One of the other big boons (and possibly the reason I might use a farm like this) is for testing.

It doesn’t really matter how powerful your laptop is, you are never going to be able to build a truly enterprise farm on it (with redundancy in all places and all of the lights and switches turned on). The same credit you get in Azure could be used to model and build massive farms you could use for testing new topologies, or testing load balancing scenarios, or performance and load testing?)

Don’t forget, you only pay for the machines while they are turned on so instead of running 1 XL VM for 20 days a month .. why not create 30 Large VMs and run them for 5 days a month of testing?

Conclusion…
Well, this is a very interesting move from Microsoft .. and stacked up alongside their hosted Team Foundation Server offering this does create a very attractive and extremely low-cost cloud-based development scenario.

It encourages people to stick with MSDN and give Azure a go for development and testing, and I’m sure this will end up leading to many companies taking a much closer look at how Azure works for their production environments as well.

For me ? Well .. I might well use it for the next time I do a Kerberos / Load Testing presentation (the idea of setting up a massive 20 server farm to run for a few days for free sounds pretty cool and a great learning experience to boot).

If nothing else, I’m tempted to setup a VM which I leave turned off and only use it in emergencies (my laptop is broken / stolen  or my VMs are dead for some reason).

Either way .. if you have an MSDN subscription, head over and take a look. You might be surprised how useful it is!

I’m speaking at SharePoint Connections Amsterdam 2013

SharePoint Connections Amsterdam is now in its third year and has established itself as one of the key annual SharePoint conferences in Europe. Running across two days in November It has an awesome line-up of speakers covering a huge range of topics from IT Pro, Dev (and one track which aims to cover both), Business, End User and even an Office 365 track.

This year SharePoint Connections Amsterdam 2013 will take place at the Meervaart Theatre in Amsterdam on the 19th & 20th November 2013 and I have been honoured to be invited to be one of the speakers in the IT Pro / Dev track.

My session will be all about the new Search capabilities in SharePoint 2013, so if you want to know more about Result Sources, Result Types, Query Rules and Display Templates then this is the session for you!

I’m speaking on the Tuesday at 1:25pm in Room B (either side of sessions by Joel Oleson and Spencer Harbar so no pressure eh?) Edit  – Agenda Change .. I’m speaking on Tuesday at 4:30pm in Room B

For more information about the venue, hotels, the speakers, and (most importantly) the sessions and agenda head on over and grab yourself a ticket (before they all go!)

Sign up for the event here and use discount code SP333 for 10% off when you book!

Changing Site Contents from a Grid to a List

This is something that has been bugging me for a while, and something that has clearly been bugging my users (as they keep saying they can never find anything).

The problem with the tile view is that you have to scan both left-right as well as up-down to find the item you are looking for. With a large number of lists this quickly becomes extremely painful to find what you are looking for.

The standard “Site Contents” view .. in all its nasty tile-layout glory

So I thought, how could you turn it back?

Well, the good news is that the Site Contents view is actually all formatted using CSS with unique IDs and classes, which makes it a snip. the sample I’ve done below is in jQuery (because it is easy to pin a JavaScript file to every page and it works with Office 365 just as well).

So first off we need ourselves a function to reset all of the

function HideTiles() {
  $(“#applist .ms-vl-apptile”).css({ “display”: “block” });
  $(“#applist .ms-vl-apptile”).css({ “min-height”: “50px” });
   $(“#applist .ms-vl-appinfo”).css({ “min-height”: “50px” });
  $(“#applist .ms-vl-appinfo”).css({ “width”: “500px” });
  $(“#applist .ms-vl-appimage”).css({ “height”: “50px” });
  $(“#applist .ms-vl-appimage”).css({ “width”: “50px” });

  $(“#applist #apptile-appadd .ms-vl-appimage”).css({ “width”: “96px” });

  $(“#applist .ms-vl-appimage a.ms-storefront-appiconspan”).css({ “height”: “50px” });
  $(“#applist .ms-vl-appimage a.ms-storefront-appiconspan”).css({ “width”: “50px” });
  $(“#applist .ms-vl-appimage a.ms-storefront-appiconspan”).css({ “line-height”: “50px” });

  $(“#applist img.ms-storefront-appiconimg”).css({ “height”: “50px” });
  $(“#applist img.ms-storefront-appiconimg”).css({ “line-height”: “50px” });
  };

Then we need to actually make sure this gets executed. The problem here is that the Site Contents is rendered on-the-fly using JavaScript so we have to resort to a little Script on Demand to get this working.  

$(function () {
  ExecuteOrDelayUntilScriptLoaded(HideTiles, “sp.ui.allapps.js”);
});

Then the only thing needed is to make sure this script gets dropped onto the page and I’ve done this using a Custom Action (I could have used a delegate control with CSS style tags but that doesn’t work in the Sandbox, i.e. Office 365)

<CustomAction
  ScriptSrc=~SiteCollection/_layouts/15/MJH.JSLink/MJH.AddCss.js
  Location=ScriptLink
  Sequence=20>
</CustomAction>

So if you set this up it looks something like this.



New formatting (in a single alphabetical list)

Now I admit, the formatting is pretty crude and it could do with a certain amount of smartening up, but the principle is sound and at least the owners of sites with large numbers of lists get an easier to navigate list which is alphabetical, instead of having to scan a page of dozens of tiles.

JSLink and Display Templates Part 5 – Creating custom List Views

This post will look at a slightly different scenario – List Views. The general principles are the same (we write some JavaScript which tells SharePoint to override the rendering of various elements) but because we are now dealing with a whole view instead of just a single field there are some new elements to play with.

This is actually one of the more simple examples so I’ll start with all of the JavaScript in one block

var mjhViews = mjhViews || {};

mjhViews.itemHtml = function (ctx) {
  var returnHtml = “<h2>” + ctx.CurrentItem.Title + “</h2>”;

  if (ctx.CurrentItem.MyCustomField) {
    returnHtml += “<p>” + ctx.CurrentItem.MyCustomField + “</p>”;
  } 
  return returnHtml;
};

(function () {
  var mjhOverrides = {};
  mjhOverrides.Templates = {};

  mjhOverrides.Templates.Header = “<div id=’MyCustomView’>”;
  mjhOverrides.Templates.Item = mjhViews.itemHtml;
  mjhOverrides.Templates.Footer = “</div>”;
 
  mjhOverrides.ListTemplateType = 104;
  mjhOverrides.BaseViewID = 1;
 
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(mjhOverrides);
})();


So we start off as good JavaScript developers and create ourselves a namespace (mjhViews) for our function (so we don’t pollute the global namespace). This contains a single function (mjhViews.itemHtml) which accepts the same render context object we’ve been using throughout this series.

The itemHtml method simply returns some basic HTML consisting of the item Title in an H2 element followed by the “MyCustomField” (if it exists, this field was used in Parts 3 and 4). Of course there are different methods for retrieving the values of the current item but the render context will automatically provide properties for the basic data types (some field types, external data fields in particular, don’t work like this and you might need to get creative with AJAX REST calls but be careful about performance!).

Finally we have our anonymous function which actually registers this override with SharePoint, and this is where things get interesting.

The main thing you might notice here is that we aren’t controlling any specific fields but instead override the “Header” and “Footer” with plain old HTML. For the “Item” we reference our rendering method and this will be executed for every item present in the view.

We then have two more properties (both of which are optional by the way).
The ListTemplateType and the BaseViewID both define which specific list types and views this rendering should be used for. If you don’t specify values for these then when this rendering override is registered it will override EVERY list and view on the page.

Finally we use the same old RegisterTemplateOverrides to tell SharePoint to process our object and do its thing!

Now before I apply this view it looks like this (which should be a pretty familiar SharePoint view):

Standard SharePoint list view

Once I apply my custom view rendering it looks like this:

A custom (if slightly boring) list view done with JavaScript

So .. quite easy huh? But the bright among you might have wondered .. where the hell has the toolbar and paging gone? Ahh .. yes .. that is all handled by the header and footer.

The header and footer contain important List View elements

This isn’t the only setback, if you try to use the view I defined above in “Quick Edit” mode then you also get the following error message:

TypeError: Unable to get property ‘style’ of undefined or null reference

The problem is that if you don’t override the Header you get some slightly funky behaviour because the headers injects a table object and it expects your content to be rendered inside that HTML table as rows. So by default I end up with the following (note the headers are at the bottom!)

Custom rendering with the header intact, but column headers are appearing AFTER the other content

So if you really want to play ball with the list views (and want the headers to be available) then you need to use TR and TD elements for your render HTML. For example:

mjhViews.itemHtml = function (ctx) {
  // start with a <tr> and a <td>
  var returnHtml = “<tr><td colspan=’3′>”;

  returnHtml += “<h2>” + ctx.CurrentItem.Title + “</h2>”;

  if (ctx.CurrentItem.MyCustomField) {
    returnHtml += “<p>” + ctx.CurrentItem.MyCustomField + “</p>”;
  }
  // close off our <td> and <tr> elements
  returnHtml += “</td></tr>”;
  return returnHtml;
};
Once we put this in place, our headers are back in the right place.

Custom rendering with column headers in the right place

Making your views use the correct Display Template
In order to make sure the Display Templates are used in the correct places you have a number of options.

  1. In your schema.xml of a custom list definition you can define the JSLink property allowing you to override specific views. This allows you to build List Templates which have completely bespoke views when required (especially useful for use with list view web parts)
  2. You can define the JSLink property on the List View Web Part .. and this works either for defined views in the List or for List View Web Parts which you have dropped onto other web part pages or publishing pages.
  3. You can use Code / PowerShell to modify the JSLink property of the SPView object programmatically
  4. You can of course just drop in your JavaScript file using a Script Editor or custom Master Page and use the ListTemplateType and BaseViewID properties I told you about at the beginning on this post :)
  5. or you can use a funky new method which allows users to create their own views using your custom templates … but more about that in Part 6 :)

So that pretty much covers off how list views can be rendered using bespoke code. Hope you’ve been enjoying the series but we’re not done yet!

..

Next – Part 6 – Creating View Templates and Deployment Options (coming soon)

« Older Entries