cancel
Showing results for 
Search instead for 
Did you mean: 

Azure Storage Blob - Could not load file or assembly 'System.Memory

MateuszWojcik
Level 5
Hi,

I have written code in Visual basic to connect to Azure Storage Blob and download it.
It works on Visual Studio IDE but when I try to create an object based on the code I am still getting errors "could not load file or assembly.
The full error message:  Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

External References:
System.dll
System.Data.dll
System.Xml.dll
System.Drawing.dll
System.Core.dll
Azure.Core.dll
Azure.Storage.Blobs.dll
netstandard.dll
Azure.Storage.Common.dll
System.Runtime.dll
System.Memory.dll

Namespace Imports:
System
System.Drawing
System.Data
Azure.Storage.Blobs
Azure.Core
Microsoft.VisualBasic
Azure
System.Runtime

MyCode:
'Declare variables
Dim SAS_Token As String
Dim Blob_Url As String
Dim destination_pat As String

'Variables
SAS_Token = "sv=2020-07-04&st=2019-03-14714%3A12%3A54Z&se=2025-12-31T14%3A12%3A00Z&sr=c&sp=rdl&sig=YTryIR1idyBn3sK720o5ZBa9TjJ7rwrBW62pV0%3D"
Blob_Url = "https://servernew.blob.core.windows.net/bot-new/QA/83e65d5.zip"
destination_pat = "C:\Users\BOT222\Desktop\New folder\test.zip"

'Create serviceUri object
Dim serviceUri As New Uri(Blob_Url)
'Create sasCredential object
Dim sasCredential As New AzureSasCredential(SAS_Token)
'Create BlobClient object
Dim blobClient As New BlobClient(serviceUri, sasCredential)


blobClient.DownloadTo(destination_pat)

Do you have idea what should be done to make this code works or do you have ready object to work with?

Thank you in advance
3 REPLIES 3

ewilson
Staff
Staff
@Mateusz Wojcik,

This error pops up from time-to-time when you start pulling in various external libraries. It comes down to a conflict between dependencies of one or more of the external libraries you're trying to use and libraries that Blue Prism is using. Starting back in v6.6, I think, Blue Prism started making heavy use of binding redirects which contributed to this.

The solution is to find a version of the 3rd party libraries that use dependent libraries (in this case System.Memory.dll) that don't conflict with what Blue Prism expects via it's binding redirects. Here's a screenshot of the Automate.exe.config from my BP v6.10.4 installation:

37053.png
You can see the reference to System.Memory.dll here and it tells you exactly what Blue Prism expects. You should also find a copy of this DLL in the Blue Prism Automate folder.

Cheers,
Eric​

MateuszWojcik
Level 5
Hi Eric,
I have already found it in Blue Prism folder, you can see that I put it on External References. But I still get the following error.

ewilson
Staff
Staff
Hi @Mateusz Wojcik,

Have you made any progress on this? You mentioned that you tested this in Visual Studio and it worked. My guess is there an additional library (one referenced by System.Memory) that's at play here. You might take a look at the Debug or Release folders under your VS application and see what additional libraries are there. You could then copy those in place of any existing DLLs in the BP Automate folder. WARNING: Just make sure you create copies of any existing DLLs before you replace them.

Cheers,
Eric