AdamLeffert-5988 avatar image
0 Votes"
AdamLeffert-5988 asked LeifSegenPFA-3161 published

.Net Framework 4.8, Azure.Storage.Blobs 12.8.0, UploadBlob could not load file or assembly System.Buffers

.Net Framework 4.8 is my target platform (WinForms).

I created a .Net Framework 4.8 unit test project, to isolate the code.

C# project. VS 2019 Pro, latest (as of 2/26/21).

Azure subscription. Created a storage account.

Test project has auto generate binding redirects enabled. I tried disabling it and creating specific binding redirects. Didn't help.

Code to allocate a BlobContainerClient works. Properties of this object are populated.

using (var stream = new MemoryStream(byteArray))
client.UploadBlob("test blob", stream);

fails. byteArray is allocated and filled.


System.IO.FileLoadException: 'Could not load file or assembly 'System.Buffers, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

Excluded any other code from the unit test project that could be causing a conflict.

If Azure.Storage.Blobs needs this version of System.Buffers, shouldn't ASB include this reference automatically?

Trying to add this System.Buffers reference via NuGet doesn't work. There is no publicly available version 4.0.2 of this package. Earlier or later packages don't work.

How to get this code to work?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

deherman-MSFT avatar image
0 Votes"
deherman-MSFT answered LeifSegenPFA-3161 published

Here is a Stack Overflow thread where they were able to resolve a similar issue with the same System.Buffers error. Try this out and see if it resolves your issue. If not, I recommend filing this as a bug on the SDK issues page.

Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm not seeing the link to that thread. Might sharing again?

0 Votes 0 ·
AdamLeffert-5988 avatar image
0 Votes"
AdamLeffert-5988 answered deherman-MSFT commented

Thank you for your quick reply.

Three parts to this reply:

1) It works now.
2) What I think happened.
3) We need better Visual Studio tooling around this.

1) It works now.

As I started to work through the suggestions on the StackOverflow page, some seemed like good ideas and some seemed like setting up fragile situations that will just break later. I will explain in item #3.

As I worked through the suggestions, I was carefully writing up a reply stating that there were only 3 NuGet packages in my test project:

a) MSTest.TestAdapter
b) MSTest.TestFramework
c) Azure.Storage.Blobs, v. 12.8.0

As I started to type out "The two NuGet packages for unit testing couldn't be the problem" I realized there was no logical reason this must be true. I had unconsciously assumed that unit test packages were clean or special in some way that would prevent them from causing conflicts. Turns out this isn't true.

I took the exact same code, moved it to a .Net Framework 4.8 console app and it runs fine.

2) What I think happened.

NuGet UI (in Visual Studio) says that MSTest.TestFramework has no dependencies.

MSTest.TestAdapter depends on

if I'm reading the NuGet dialog correctly.

Note that none of these words mention System.Buffers. Is there some chain of dependencies that includes System.Buffers? No reasonable way for me to know.

What I think happened, and please read this closely, is that MSTest.TestAdapter caused Azure.Storage.Blobs to try to load an OLDER version of System.Buffers (, which is not even available via NuGet or through the command-line package manager, as far as I can tell.

Bad enough if MSTest needs a new version and Azure.Storage.Blobs needs an old version, except that's not what happened, and both of these packages are new.

Please correct me if I'm misinterpreting, but I think I just spent an entire day (actually more) determining that the unit test package causes the Azure blobs package to try to use an outdated version of System.Buffers. This info is not available at any top-level UI that I can find in VS or NuGet. Maybe it is imputable through some amount of sleuthing of dependencies.

Which brings me to #3.

3) We need better tooling around this.

Or, failing that, we need a video explaining how to troubleshoot these situations.

I tried auto-generating redirects. I tried manual redirects. Even if manual redirects worked, I'm concerned that I'd only be kicking the can down the road, and that adding another NuGet package would cause a new conflict.

I get that dependencies exist. I'm OK with some amount of fiddling. But having two brand-new packages force the code to find an old one that isn't published is scary.

If I'm misunderstanding how this stuff works, please correct me.

Otherwise, we need to make this easier. I've been a dev for over 40 years. I've been a MS dev for 20 years. I architect/code/mentor over 40 hours a week, every week. This is too much to put on devs, from junior to senior.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For your issues with Visual Studio I recommend reaching out here. For MSTest I recommend posting an issue on GitHub or you can also report a problem under .NET on the Developer Community page. I have reached out privately to work with you regarding the Storage specific asks and issues.

1 Vote 1 ·