Could not load type 'Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.0.0
Asked Answered
M

2

7

I am running a custom activity in Azure data factory, when i am trying to work on CloudAppendBlob the following exception occurs. It looks like a version issue but not able to figure a way to fix. I have compiled the code using Windows Azure Storage 7.0.0. Please help!

Unknown error in module:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. at MyDotNetActivity.SampleActivity.Execute(IEnumerable1 linkedServices, IEnumerable1 datasets, Activity activity, IActivityLogger logger) at Microsoft.Azure.Management.DataFactories.Runtime.ActivityExecutor.Execute(Object job, String configuration, Action`1 logAction) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.DataPipeline.Compute.HDInsightJobExecution.ReflectingActivityWrapper.Execute() in f:_Bld\12752\4106\Sources\Product\Common\Compute\src\HDIComputeDelegatorJob\ReflectingActivityWrapper.cs:line 44 at Microsoft.DataPipeline.Compute.HDInsightJobExecution.JobWrapper.RunJob() in f:_Bld\12752\4106\Sources\Product\Common\Compute\src\HDIComputeDelegatorJob\JobWrapper.cs:line 94 at Microsoft.DataPipeline.Compute.HDInsightJobExecution.Launcher.Main(String[] args) in f:_Bld\12752\4106\Sources\Product\Common\Compute\src\HDIComputeDelegatorJob\Launcher.cs:line 78.

Mayhem answered 23/6, 2016 at 10:31 Comment(4)
Are you sure you're using version 7.0.0.0 of the library? From the error it seems you're using 4.3.0.0.Pickmeup
Seems like you need to update your project's assembly binding.Pretty
Where do you run your app? May be, you already have the 4.3.0.0 version in GAC, and your app load it from there.Huckster
I run the app in Azure, here is the link I follow azure.microsoft.com/en-in/documentation/articles/… and example for Append blob is here azure.microsoft.com/en-in/documentation/articles/…Mayhem
V
7

I have run into the same problem myself. Turns out Azure Data Factory is restricted to version 4.3 of Microsoft.WindowsAzure.Storage. In order to load a different version you should take a look at Microsoft's CrossAppDomainDotNetActivitySample.

From the readme:

This sample allows you to author a custom .NET activity for ADF that is not constrained to assembly versions used by the ADF launcher (e.g., WindowsAzure.Storage v4.3.0, Newtonsoft.Json v6.0.x, etc.).

The code includes an abstract base class (CrossAppDomainDotNetActivity) that implements app-domain isolation and a sample derived class (MyDotNetActivity) that demonstrates using WindowsAzure.Storage v6.2.0.

Note: The public types exposed by the ADF SDK are not serializable across app domain boundaries. As such, the derived class must provide pre-execution logic (PreExecute) to process the ADF objects into a serializable object that is then passed to the core logic (ExecuteCore).

Valeric answered 24/8, 2016 at 4:18 Comment(1)
This is a known limitation of the DotNetActivity - and the recommended workaround is the one Mitchell mentions here. social.msdn.microsoft.com/Forums/vstudio/en-US/…Greensickness
M
0

In your app.config, add the following assembly binding redirect:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
  </dependentAssembly>

If you encountered other similar issues afterwards, add assembly binding redirects for those assemblies as well.

Murmurous answered 24/6, 2016 at 2:5 Comment(2)
Thanks for the answer, but exception persists even after adding the assembly binding redirect. And my app.config is having the codeMayhem
'<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>'Mayhem

© 2022 - 2024 — McMap. All rights reserved.