System.Text.Encoding.CodePages depencency problem #325

Open
opened 2026-01-29 22:10:09 +00:00 by claunia · 8 comments
Owner

Originally created by @Tealons on GitHub (Sep 10, 2018).

I have a MVC function that I'm migration to an Azure Function. During the migration, I ran in some kind of dependency problem:

image

FileLoadException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Somehow there is a problem concerning netstandard2.0 and sharpcompress 0.22.0. I'm not sure what the cause is, but downgrading to 0.21.0 solved it.

Maybe I can help somebody to save the hours that I lost figuring this out. And maybe a fix can be created for 0.23.0?

If any extra information is needed, just let me know.

Originally created by @Tealons on GitHub (Sep 10, 2018). I have a MVC function that I'm migration to an Azure Function. During the migration, I ran in some kind of dependency problem: ![image](https://user-images.githubusercontent.com/7141563/45299476-07ce5d80-b50c-11e8-8550-c55d1a3e463f.png) FileLoadException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Somehow there is a problem concerning netstandard2.0 and sharpcompress 0.22.0. I'm not sure what the cause is, but downgrading to 0.21.0 solved it. Maybe I can help somebody to save the hours that I lost figuring this out. And maybe a fix can be created for 0.23.0? If any extra information is needed, just let me know.
Author
Owner

@adamhathcock commented on GitHub (Sep 10, 2018):

Looks like updating the CodePages version to 4.5.0 from 4.4.0 busted it.

I have a feeling it's to do with the recent stuff talking about now .NET 4.6.1 isn't really supported by .NET Standard 2.0 since it was retrofitted. Discussed around here: https://github.com/dotnet/standard/issues/481 or https://github.com/dotnet/standard/issues/514

There was a tweet thread I can't find but blamed it on that.

It looks like Azure Functions 2.0 is .NET Core so maybe try that :)

@adamhathcock commented on GitHub (Sep 10, 2018): Looks like updating the CodePages version to 4.5.0 from 4.4.0 busted it. I have a feeling it's to do with the recent stuff talking about now .NET 4.6.1 isn't really supported by .NET Standard 2.0 since it was retrofitted. Discussed around here: https://github.com/dotnet/standard/issues/481 or https://github.com/dotnet/standard/issues/514 There was a tweet thread I can't find but blamed it on that. It looks like Azure Functions 2.0 is .NET Core so maybe try that :)
Author
Owner

@Tealons commented on GitHub (Sep 10, 2018):

That's not possible (yet): https://github.com/Azure/Azure-Functions/issues/805

@Tealons commented on GitHub (Sep 10, 2018): That's not possible (yet): https://github.com/Azure/Azure-Functions/issues/805
Author
Owner

@adamhathcock commented on GitHub (Sep 10, 2018):

I don't see the issue if your libraries all target netstandard20. You should be targetting that with everything except the actual executable which could be netcoreapp20 or netcoreapp21.

I'm just guessing that the azure function itself is just a library (targetting netstandard20) since the instance is the loading the library to execute it. Azure Functions v1 is net461 or something and Azure Functions v2 is netcoreapp20.

@adamhathcock commented on GitHub (Sep 10, 2018): I don't see the issue if your libraries all target netstandard20. You should be targetting that with everything except the actual executable which could be netcoreapp20 or netcoreapp21. I'm just guessing that the azure function itself is just a library (targetting netstandard20) since the instance is the loading the library to execute it. Azure Functions v1 is net461 or something and Azure Functions v2 is netcoreapp20.
Author
Owner

@Tealons commented on GitHub (Sep 10, 2018):

In the issue I references, you can find a link to https://github.com/Azure/azure-functions-vs-build-sdk/issues/160#issuecomment-386402717. You can compile with targetframework netcoreapp20, but it crashes with a runtime error...

@Tealons commented on GitHub (Sep 10, 2018): In the issue I references, you can find a link to https://github.com/Azure/azure-functions-vs-build-sdk/issues/160#issuecomment-386402717. You can compile with targetframework netcoreapp20, but it crashes with a runtime error...
Author
Owner

@andrx commented on GitHub (Dec 20, 2019):

Building lambda function for aws. have the same issue. when downgraded back to 4.5.1 started working.

@andrx commented on GitHub (Dec 20, 2019): Building lambda function for aws. have the same issue. when downgraded back to 4.5.1 started working.
Author
Owner

@manfred-brands commented on GitHub (Jun 14, 2022):

We have the same issue where SharpCompress is the only project pulling in System.Runtime.CompilerServices.Unsafe version 5.0.0. Other code pulls in 4.5.3 (file version 4.0.4.1) through System.Memory.

It doesn't look SharpCompress needs that later version.

@manfred-brands commented on GitHub (Jun 14, 2022): We have the same issue where SharpCompress is the only project pulling in `System.Runtime.CompilerServices.Unsafe` version 5.0.0. Other code pulls in 4.5.3 (file version 4.0.4.1) through System.Memory. It doesn't look SharpCompress needs that later version.
Author
Owner

@SplitGemini commented on GitHub (May 9, 2023):

.net 4.8 same

@SplitGemini commented on GitHub (May 9, 2023): .net 4.8 same
Author
Owner

@SplitGemini commented on GitHub (May 21, 2023):

Any updates?

@SplitGemini commented on GitHub (May 21, 2023): Any updates?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#325