question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SetSecretAsync gives error "Could not load file or assembly 'System.Text.Encodings.Web"

See original GitHub issue

Describe the bug

When I call SetSecretAsync() method, I’m having above error.

Could not load file or assembly ‘System.Text.Encodings.Web, Version=4.0.5.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’. The system cannot find the file specified.

Expected behavior App should save the given secret to Azure vault.

Actual behavior (include Exception or Stack Trace) SetSecretAsync fails with the above exception

Previously I had following error too and I solved after upgrading Azure.Security.KeyVault.Secrets to v 4.2.0

Method not found: ‘System.Text.Json.JsonEncodedText System.Text.Json.JsonEncodedText.Encode(System.String, System.Text.Encodings.Web.JavaScriptEncoder)’.

To Reproduce

string vaultUrl = MyUrls.ConnectorKeyVaultUrl;

var client = new SecretClient(vaultUri: new Uri(vaultUrl), credential: new DefaultAzureCredential());

result = await client.SetSecretAsync(key, value);

Environment:

<PackageReference Include="JWT" Version="8.2.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Azure.Identity" Version="1.4.1" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.2.0" />
  • Mac OS - .Net Core 3.1
  • IDE and version : [e.g. Visual Studio mac 16.3]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
msftbot[bot]commented, Sep 22, 2021

Hi, we’re sending this friendly reminder because we haven’t heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

1reaction
heathscommented, Sep 10, 2021

I’m assuming you mean “functions”, but can you clarify what the “functions app” is? Are you talking about the Azure Functions SDK / test host? Did you try updating to the latest Azure Functions SDK or do any host logging?

The Key Vault SDK - all our latest SDKs, actually - will automatically pull in a new versions, but if the host application is ignoring that DLL and loading an older version (which has a security vulnerability), the host application needs to be updated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "Could not load file or assembly" in .net core 3.1 ...
In my case problem was solved by adding to project file following xml <ItemGroup> <FunctionsPreservedDependencies Include="System.Text.
Read more >
Azure functions: Could not load file or assembly System. ...
What I've tried so far: Because the missing dll was getting purged from the output directory (bin/Debug/netcoreapp3.1/bin) I've tried to ...
Read more >
Azure Functions - Could not load file or assembly System. ...
This post is about how to fix the exception Could not load file or assembly System.Text.Encoding.CodePages when you're using any HTML parser ...
Read more >
Error loading assembly using Graph API
I tried using the Modules panel in Visual Studio to figure out which version of System.Text.Encodings.Web is actually being loaded (as described ...
Read more >
Could not load file or assembly 'Azure.Core
During this implementation, we are getting below error: Error Message: System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found