Category Archives: Uncategorized

Windows 8 Setup: Setup has failed to apply migration data

I imagine there are a lot of ways a Migration installation on Win 8 could fail, but just to share my fix…

I did a Windows 8 Upgrade from Windows 7, and about 30% into the Migration phase, this error:

Setup has failed to apply migration data.

… Followed by a rollback to Windows 7.

This error tells you nothing – very frustrating. Look in the logs located in C:\$WINDOWS.~BT\Sources (surf around in there and you’ll find the log file that applies, possibly in the \Migration folder).

In my case, I noticed an entry that pointed to a Migration Error – it couldn’t move my desktop.ini file in my Music folder. It was looking for C:\Users\bpotter\Music\desktop.ini and couldn’t find it, failed the migration, and triggered a rollback.

I deleted the desktop.ini file (I don’t really care if I lose the folder view settings for my Music folder) and the install and migration completed successfully.

Testing how Smooth Streaming chokes

Just for fun, I tested Big Buck Bunny being served through IIS Media Services from the local disk, running on an Amazon EC2 Micro instance (the smallest available). This is a fairly lightweight server, i.e. something you would never want to run in a production environment. Consider this the streaming equivalent of “Will it Blend?”…

The results are in – when it’s going well, it’s surprisingly great, and when it’s not going well, it’s terrible. 😉

Total Chunks: 2691
Chunks Tested: 2691
Manifest Download Time: 310ms
Avg Video Chunk Response Time: 357ms
Avg Audio Chunk Response Time: 61ms

Excellent Chunks: 590 (21.92%)
Good Chunks: 1821 (67.67%)

Warning Chunks: 68 (2.53%)
Degraded Chunks: 6 (0.22%)
Poor Chunks: 206 (7.66%)

Stream 0: video, 2962kbps, 2056kbps, 1427kbps, 991kbps, 688kbps, 477kbps, 331kbps, 230kbps
Stream 1: audio, 128kbps

Things go OK around 89% of the time. But when they don’t, it crashes and burns…

image

Yikes. You can almost feel the Silverlight players freaking out. 😉

IIS Smooth Streaming Performance Testing Tool

If you are deploying a Smooth Streaming infrastructure, you already know it’s all HTTP-based. Requests for little video chunks hit your web server, and your web server looks up the correct video “chunk” within the audio/video file and serves it up.

However, it’s can be difficult to get a good benchmark on how your infrastructure is doing at serving up chunks, especially when your Silverlight clients are seeing random buffering errors or you run into scaling problems.

First off, there is a lot of information available from the Smooth Streaming Health Monitor app – In a couple seconds you can have a trace of what decisions the Silverlight Adaptive Streaming Media Element is making and export that out to Excel.

But when you just need comprehensive chunk data on all bitrates to diagnose how your origin/CDN is doing, I made this app (almost called it “Chunker”):

image

Enter the manifest URL of the on-demand smooth stream you want to test (note that this does not currently support live or composite manifests), for example: http://server.com/streams/BigBuckBunny.ism/Manifest

Once you click Begin Test, a new test tab will open and start requesting chunks based on the manifest information. The results will tell you if you may have a problem with your disk IO on your origin or some other problem preventing chunks being delivered in a timely manner.

Note: Only the first 1000 bytes (almost 1K) of each chunk is downloaded. The point here is not to test bandwidth, but rather test your infrastructure’s performance as it relates to reading/seeking fragments and assembling chunks.

Hopefully based on the assessment of each chunk, you can get an idea of how your CDN / origin / standalone box is doing at delivering chunks.

Run Smooth Stream Performance Testing Tool (ClickOnce)

Punished for not installing a toolbar!

This one was a new one… I thought having to avoid toolbars bundled with the application I actually wanted was the punishment, but here’s a new one: When I unchecked “Install the new Bing Bar”, the Next button actually turned into a disabled 30-second countdown!

image 

I guess this is a new technique… Punish with Patience. 😉

MOSS 2007: Get Feature ID the easy and lazy way

Quick MOSS tip-o-the-day:

If you need to retrieve the ID (GUID) of a Feature, for running STSADM commands, etc, there’s a quick and easy way to do this for features that are currently activated:

1. Go to your Site Settings, where your features are listed and you see the Activate/Deactivate buttons.

image

2. Press the Deactivate button (don’t worry, this goes to a confirmation page, so you’re not causing anything to happen yet)

image

3. While you’re on the confirmation page, take a look at your browser address bar – voila, your feature ID:

http://server/_layouts/DeactivateFeature.aspx?FeatureId=f6924d36-2fa8-4f0b-b16d-06b7250180fa

image

Enterprise MOSS 2007: Event Receivers and threads don’t mix

MOSS provides an Event Receiver model you can use to perform actions when something happens (i.e. a list item is updated). This is somewhat described here:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverbase.aspx

It can be easy to end up in a loop here; for example, if you handle the ItemUpdated event, and you update the item again inside your event receiver, then your event receiver is going to fire again, causing you to update the item again, which will cause the event receiver to fire, causing you to … well, you get the picture.

SharePoint does have built-in protection for this problem, though – it will only allow a “depth” of 10 recursive events to fire.

Additionally, to solve this problem, the SharePoint object model provides two methods that can prevent this:

image

This all works great, but the solution I was working with on this problem required a somewhat “mass processing” of a bunch of list items. To do this, the event receiver spawns a few new threads for processing list items. We started getting some very weird errors – my favorite?

WebPartPageUserException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

In any case, what we actually found was that DisableEventFiring and EnableEventFiring, quite frankly don’t do jack when it comes to other threads. Why?

They set a property in the SPEventManager class:

image

Which, in turn, flags some data on the current thread!

image

On one hand, this makes sense, from the HTTP model perspective (you don’t want to disable events globally, because other updates coming from a browser wouldn’t fire the initial events while you were still processing yours), but at the same time, it’s far from obvious that asynchronous multithreading is not supported in the event model.

Lessons learned:

  • The SharePoint event model is NOT friendly to multi-threading. If possible, offload asynchronous operations to a timer job or another method that will take place in a single thread / SharePoint request context.
  • For multi-threaded operations, make sure the threads you spawn disable events before updating any items, to avoid an infinite loop.

Enterprise MOSS 2007 Performance Gotcha: ConsoleNode / Editing Toolbar Customization

There is a severe problem with the SharePoint 2007 ConsoleNode. In particular, you can run into an astonishing performance loss when attempting to build a dynamic menu that can change depending on page state. The Microsoft.SharePoint.Publishing.WebControls.ConsoleNode class is a base class that you inherit to customize the SharePoint Editing Toolbar.

image

In the above image, the “Page”, “Workflow”, and “Tools” options, for example, are ConsoleNodes.

The high level implementation goes like this:

  1. Create a class – let’s say, MyConsoleNode – that inherits from Microsoft.SharePoint.Publishing.WebControls.ConsoleNode.
  2. Override the GET property accessor for ChildConsoleNodes, shown below.

    image

  3. When SharePoint requests the ChildConsoleNodes property, you build a few child nodes that will be displayed in the dropdown menu, and add them to the base.ChildConsoleNodes collection.

This is the pattern that Microsoft uses for their Out-of-the-Box console nodes as well.

The Problem

This appears to be a fairly straightforward pattern, and works well, until you start doing any significant calculations to build your Child Node collection. The reason is that, in my testing, this property gets called 12+ times per page load. Hang on, because this journey is not over…

Most normal developers would solve this problem with a simple boolean flag, say in the current HTTP request, that indicates whether or not you have already built your child nodes, and if so, don’t do it again. Do NOT do this! You will most likely end up with a completely blank child menu, and start to question why you became a SharePoint developer.

This is the way that MyConsoleNode is used by SharePoint when it renders the page; my best guess is that it’s done this way to calculate permissions. For the purposes of my example, we’ll assume that 2 child console nodes are built.

  1. HTTP request begins, and SharePoint starts to build the page.
  2. A new instance of MyConsoleNode is instantiated (we’ll call this Instance A).
  3. GET ChildConsoleNodes is called (Instance A), no existing child nodes.
  4. GET ChildConsoleNodes is called (Instance A), 2 child nodes are already present.
  5. A new instance of MyConsoleNode is instantiated (Instance B).
  6. GET ChildConsoleNodes is called (Instance B), no existing child nodes.
  7. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  8. GET ChildConsoleNodes is called (Instance B), 0 child nodes already present.
  9. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  10. GET ChildConsoleNodes is called (Instance B), 3 child nodes already present [don’t ask – I don’t know].
  11. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  12. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  13. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  14. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  15. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present.
  16. Page is rendered.

It’s fairly obvious why a simple boolean flag will not work, for two reasons:

  • The class is instantiated twice (once in Step 2, again in Step 5).
  • Even when the class is not instantiated again, in Step 8, the previously added child nodes are gone.

There’s another mystery of why there are 3 child nodes in Step 10, but I didn’t really care to research that one.

The Solution

If you want to solve this problem, you will, unfortunately, have to use reflection to get an internal property value. I am not going to post the code to do this, because it is not guaranteed to survive a MOSS Service Pack upgrade or translate into future versions of SharePoint, and you will have to make some decisions in your code as to what to do if this property disappears at some point.

The key to solving this problem is a boolean internal property of ConsoleNode called ReadyToCreateChildNodes.

image

If you look at a Microsoft out-of-the-box Console Node (for example, let’s check out ModifyWebPartsNode) you’ll see a method called EnsureChildNodes():

image

In the code of this method, Microsoft internally checks for this condition:

image

As a side note, in my testing, I did also duplicate the ConsoleNode.IsValidStateForNode conditions, and they were always true; however, this depends on the permissions you’ve applied to the node, and I was using EmptyMask. But for the purposes of solving this problem, all you really need to care about is ReadyToCreateChildNodes.

Let’s look at the request again, now considering the state of this property.

  1. HTTP request begins, and SharePoint starts to build the page.
  2. A new instance of MyConsoleNode is instantiated (we’ll call this Instance A).
  3. GET ChildConsoleNodes is called (Instance A), no existing child nodes. [ReadyToCreateChildNodes = FALSE]
  4. GET ChildConsoleNodes is called (Instance A), 2 child nodes are already present. [ReadyToCreateChildNodes = FALSE]
  5. A new instance of MyConsoleNode is instantiated (Instance B).
  6. GET ChildConsoleNodes is called (Instance B), no existing child nodes. [ReadyToCreateChildNodes = FALSE]
  7. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  8. GET ChildConsoleNodes is called (Instance B), 0 child nodes already present. [ReadyToCreateChildNodes = TRUE]
  9. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  10. GET ChildConsoleNodes is called (Instance B), 3 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  11. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  12. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  13. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  14. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  15. GET ChildConsoleNodes is called (Instance B), 2 child nodes already present. [ReadyToCreateChildNodes = FALSE]
  16. Page is rendered.

Occasionally, in my testing, ReadyToCreateChildNodes in step #9 would also be in a “true” state, but for the most part, it was only true for one call. And once I built my child nodes in Step 8, they remained populated for the rest of the request.

So, to sum this all up, the solution to this problem is: Use reflection to check the internal boolean ReadyToCreateChildNodes property before you build your child nodes.

Code Access Security Policy (CASPOL.exe) GUI Utility

I find it extraordinarily difficult (okay… inconvenient?) to make Code Access Security Policy changes in the .NET Framework. After .NET 2.0, outside of the SDK, the graphical tools for doing this were no longer installed on most client PC’s. Usually, when I have to break out caspol.exe, it’s possibly because:

  1. I downloaded a third party DLL from a web site, and it’s not trusted, with no unblock option, and Visual Studio is complaining about it when I’m actually trying to get some real work done
  2. I want to run some .NET apps off a network share, and the machine I’m using doesn’t have .NET 3.5 SP1.

… and it’s used so infrequently that I have to look up all the command line options and re-learn the thing every time, not to mention when I finally get the command right, I’m not in Elevated Privileges mode (Vista / Win 7).

So, for those like me, who like GUIs, and just want to get an assembly or folder trusted and move on with life, I present to you – a GUI CASPOL command generator:

image

This supports a subset of the available CASPOL commands:

  • Single file / assembly
  • Folder path / network share
  • Different scopes (Machine / User / Enterprise)
  • Trust Level (FullTrust by default)
  • Code Groups
  • Run CASPOL command in Elevated mode

For the small executable – Download It Here (9K)

… or, here’s the source project (VS2008 / C#).