System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

创建Azure Cloud Service,本地能够正常编译,提交到Azure云平台上,提交失败。Download相关日志信息,发现报以下错误:


2/22/2016 1:24:04 PM,1070001,Error,"ObserverWorkerRole is running","{'Exp':'System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)\r\nFile name: 'Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'\r\n   at ObserverWorkerRole.WorkerRole.<RunAsync>d__0.MoveNext()\r\n   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\r\n   at ObserverWorkerRole.WorkerRole.RunAsync(CancellationToken cancellationToken)\r\n   at ObserverWorkerRole.WorkerRole.Run() in d:\\Users\\v-ruiyli\\UAir20151226\\Code\\Solutions\\All\\UAirAll\\ObserverWorkerRole\\WorkerRole.cs:line29\r\n\r\nWRN: Assembly binding logging is turned OFF.\r\nTo enable assembly bind failure logging, set the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1.\r\nNote: There is some performance penalty associated with assembly bind failure logging.\r\nTo turn this feature off, remove the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog].\r\n'}' TraceSource='WaWorkerHost.exe'"


这个错误纠结了我一天,后来我通过Azure支持才了解到了答案。


因为ServiceRunTime与Windows.Configuration版本不相容,我在代码中通过CloudConfigurationManager.GetSetting获得参数信息,因此程序异常退出。


解决方法如下:

1、对workerrole项目右键-》manage nuget packages...

2、搜索Microsoft.WindowsAzure.Configuration

3、安装,会将旧的Microsoft.WindowsAzure.Configuration.dll自动替换

4、再次提交即可。


0 条评论

    发表评论

    电子邮件地址不会被公开。 必填项已用 * 标注