System.Reflection.TargetInvocationException:FileLoadException StorageClient

Topics: Autoscaling Application Block ("Wasabi")
May 3, 2013 at 9:58 AM
Edited May 3, 2013 at 10:00 AM
I am new to Azure & c#, I just develop a Azure deployment using Autoscaling blocking.

All codes are followed this: http://www.windowsazure.com/en-us/develop/net/how-to-guides/autoscaling/.

But it don`t work, when i debug it on simulator,exceptions were raised when :
 scaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>();
i got those error message.which was not in English,

it in English should be liked that:
Microsoft.WindowsAzure.ServiceRuntime Critical: 31337 : System.Reflection.TargetInvocationException: some exception with object been invoked。 ---> System.IO.FileLoadException: can not load file or application set “Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
or its dependence. application manifest found did not matched with which referenced. (Exception from HRESULT:0x80131040).
How to fix this error?

Thanks & regards.

whole exception message:
Microsoft.WindowsAzure.ServiceRuntime Critical: 31337 : System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.IO.FileLoadException: 未能加载文件或程序集“Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
在 Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling.AzureStorage.AzureStorageAccount..ctor(String storageAccount)
在 lambda_method(Closure )
--- 内部异常堆栈跟踪的结尾 ---
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
在 System.Delegate.DynamicInvokeImpl(Object[] args)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConstantParameterValue..ctor(Expression expression)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeRegistration.BuildDependencyParameter(Expression arg)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeRegistration.<get_ConstructorParameters>b__0(Expression arg)
在 System.Linq.Enumerable.<>c__DisplayClass123.<CombineSelectors>b__11(TSource x)
在 System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()
在 System.Linq.Buffer1..ctor(IEnumerable1 source)
在 System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.GetInjectionMembers(TypeRegistration registrationEntry)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.Register(TypeRegistration registrationEntry)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer(IConfigurationSource configurationSource)
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer()
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current()
在 MonitorRole.WorkerRole.OnStart() 位置 E:\c\vc\OnvelopPaasTest\MonitorRole\WorkerRole.cs:行号 52
在 Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
在 Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)
在 Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
May 3, 2013 at 1:36 PM
What version of AzureStorage are you using? Try configuring a binding redirect to that version:
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.StorageClient" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="1.1.0.0" newVersion="2.0.5.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jun 3, 2013 at 5:22 AM
Thanks randylevy.

I am sorry that I hasnot seen your reply untill today. This email addree was not the one I usually used.

I has made my project running on Azure, the effort made to esure its running was:
1, I added libs Microsoft.WindowsAzure.StorageClient and Microsoft.WindowsAzure.ServiceRuntime to the list of references manually,
2,Accordingly I added tow runtime sections to app.config file.

It was deployed onto Azure successfully and I can log in the both VM, I guess it was ok.
The puzzle left was:
1, I has read and learnt from this document (http://www.windowsazure.com/en-us/develop/net/how-to-guides/autoscaling/), from this document, it was not said that those types of menual operation need to be done. I want to know, was it just due to a little missed content to the document , otherwise, I has execute some incorrect operation ,that on the other hand, it was not necessary for an correct developing procedure that adding those libs manually? did i mistake something or document missed something?
2, How to verify this Azure project, I think there are two steps:1, check whether the counter data was correctly saved, 2, check whether the autoscaling blob read the counter datas and react correctly. How to chech them?
could you kindly give some hints or something related documemt (or article) introduce them?

thanks a lot.

liurx_cn