Thursday, July 12, 2012

Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Have you seen the following error recently while trying to use the new Windows Azure Media Services features:

Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I received the above error while attempting to use the Windows Azure Media Services SDK v1.0 CloudMediaContext class:

return new CloudMediaContext("myAccount", "myAccountKey");

After looking at the pre-binding probe log, I found this:

=== Pre-bind state information ===
LOG: User = \
LOG: DisplayName = Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase =
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.WindowsAzure.MediaServices.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Workspaces\Windows Azure Media Services SDK Samples Project\C#\bin\Debug\MediaServicesSDKSamples.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client.DLL.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client/Microsoft.Data.Services.Client.DLL.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client.EXE.
LOG: Attempting download of new URL
file:///C:/Workspaces/Windows Azure Media Services SDK Samples Project/C#/bin/Debug/Microsoft.Data.Services.Client/Microsoft.Data.Services.Client.EXE.


It seems the Media Services DLL is dependent on the out-of-band WCF Data Services OData assembly v5.0.

There is a lot of talk on the web that these issues is due to the fact that Windows Azure Media Servers v1.0 only works with the Windows Azure SDK v1.6 and will not work with Windows Azure SDK v1.7 installed as well, for a thread on this, see here: http://social.msdn.microsoft.com/Forums/en-US/MediaServices/thread/d02e268e-e30a-481d-acb7-138646a0c4fb

But..I didn't read the pre-requisite documentation correctly and once I installed WCF Data Services v5.0 all was ok:

Figure 1: WCF Data Services 5 installer
You can find the pre-requisites here: http://msdn.microsoft.com/en-us/library/jj129588