Azure worker role throw a FileLoadException on load
by Guerrerotook on May.11, 2010, under Azure, Debugging
I’m working now on a Smooth Streaming Silverlight player for the world cup and we using Azure to host some services for the player. Recently I started the development of all those services on a Web project and when I’m trying to run the project inside the Azure Simulation Environment the web role throw me a FileLoadException.
[runtime] Role entrypoint could not be created: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Silverlight.MediaPlayer.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a10dc7bdece43c5c' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'Microsoft.Silverlight.MediaPlayer.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a10dc7bdece43c5c' ---> System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Plain\Microsoft.SmoothPlayer\Source\Azure\Microsoft.Silverlight.MediaPlayer.Online\bin\Debug\Microsoft.Silverlight.MediaPlayer.Online.csx\roles\Microsoft.Silverlight.MediaPlayer.Web\approot\bin\Microsoft.Silverlight.MediaPlayer.Web.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'file:///C:\Plain\Microsoft.SmoothPlayer\Source\Azure\Microsoft.Silverlight.MediaPlayer.Online\bin\Debug\Microsoft.Silverlight.MediaPlayer.Online.csx\roles\Microsoft.Silverlight.MediaPlayer.Web\approot\bin\Microsoft.Silverlight.MediaPlayer.Web.dll' WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
I double check that my local assembly Microsoft.Silverlight.MediaPlayer.Web.dll is there and have enough permission to read and load it. Also I enabled Fusion Log to catch the assembly fail load but I can’t find any references to my assembly… so I decided it’s time to WinDBG.
I attach to the process WaWebHost.exe (Microsoft Windows Azure Web Host), loaded all symbols and sos. The first command I wrote was !threads and I found this:
0:000> !threads
ThreadCount: 6
UnstartedThread: 0
BackgroundThread: 5
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
PreEmptive Lock
ID OSID ThreadOBJ State GC GC Alloc Context Domain Count APT Exception
XXXX 1 1ba0 000000000014c4a0 2008220 Enabled 00000000053a1c10:00000000053a1fd0 0000000002f182a0 1 Ukn System.IO.PathTooLongException (0000000005305a80)
XXXX 2 294 00000000000e46d0 b220 Enabled 00000000053d09f8:00000000053d1fd0 0000000002f17990 0 MTA (Finalizer)
XXXX 3 13b0 00000000022f9350 a802220 Enabled 0000000000000000:0000000000000000 0000000002f17990 0 MTA (Threadpool Completion Port)
XXXX 4 1a80 0000000002fbc080 80a220 Enabled 0000000000000000:0000000000000000 0000000002f17990 0 MTA (Threadpool Completion Port)
XXXX 5 1ae0 0000000002fbe650 1220 Enabled 0000000000000000:0000000000000000 0000000002f17990 0 Ukn
0 6 7e4 0000000002fe22c0 1020 Enabled 00000000053c69b0:00000000053c7fd0 0000000002f182a0 0 Ukn System.IO.FileLoadException (00000000053a7ca8)
As you can see threre are two applications domain inside this process and one of them (0000000002f182a0) have to exception in thread #1 and #6.
The exception in Thread #6 is familiar but the other thread has a System.IO.PathTooLongException.
0:001> !pe 0000000005305a80 Exception object: 0000000005305a80 Exception type: System.IO.PathTooLongException Message: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. InnerException: <none> StackTrace (generated): SP IP Function 00000000031BD360 000007FEED2D5A8F mscorlib_ni!System.IO.Path.NormalizePathFast(System.String, Boolean)+0xd0f 00000000031BD420 000007FEED239CA6 mscorlib_ni!System.IO.File.Exists(System.String)+0x96 StackTraceString: <none> HResult: 800700ce The current thread is unmanaged
So it’s seem that my path it’s too long to be loaded by the runtime!
Hope this help!
Luis Guerrero.