Azure.Security.KeyVaults.Secrets manifest mismatch, dll wont load

Bernard Alain 0 Reputation points
2024-03-11T19:48:50.4366667+00:00

https://learn.microsoft.com/en-us/answers/questions/ask/

I am trying to execute the following lines of code in a codeactivity to be used in powerapps:

//

using Azure.Core; using Azure.Identity; using Azure.Security.KeyVault.Secrets;

var client = new SecretClient(new Uri(KEY_VAULT_URI), new DefaultAzureCredential()); var secret = client.GetSecret(SECRET_NAME); CLIENT_SECRET = secret.Value.Value;

//

The codactivity is in a workflow set to on-demand and invoked using javascript by sending a REST endpoint via HTTP to the current environment. Complete reinstallation has been attempted with the project source and libraries. Binding redirects and manually editing the csproj file with broader terms for the DLL item group references were also used without much sucesss. The target framework is 4.7.1 and the libraries being used for vault access are currently as follows:

\bin\Debug\Azure.Core 1.3800 \bin\Debug\Azure.Identity 1.1100 \bin\Debug\Azure.Security.KeyVault.Secrets 4.600 \bin\Debug\Azure.Core.Experimental 0.1.0.0

Trace log:

Message: Could not load file or assembly 'Azure.Security.KeyVault.Secrets, Version=4.6.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,475 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2024-03-11T19:48:50.44+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The error message "Could not load file or assembly 'Azure.Security.KeyVault.Secrets, Version=4.6.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference" suggests that there is a version mismatch between the assembly reference and the actual assembly being loaded. You can try updating the assembly reference to version 4.600.0.0 to match the version of the assembly being loaded. Additionally, you can try clearing the NuGet cache and rebuilding the project.

    References:


  2. Akshay-MSFT 16,026 Reputation points Microsoft Employee
    2024-03-28T10:25:43.9033333+00:00

    @Bernard Alain

    Thank you for posting your query on Microsoft Q&A and apology for delay in response. I was able to review this and found a related issue reported here.

    Your service application should have a corresponding .config file e.g., if your service EXE is named myservice.exe, then you need to have a myservice.exe.config with binding redirects including:

    <dependentAssembly>
        <assemblyIdentity name="Azure.Security.KeyVault.Secrets" publicKeyToken="92742159e12e44c8" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0-4.6.0.0" newVersion="
      </dependentAssembly>
    

    See https://learn.microsoft.com/dotnet/framework/deployment/configuring-assembly-binding-redirection for more information.

    You can also auto-generate them (see bottom of that page, basically you add <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> to your .csproj) but you need to make sure that .config file gets deployed with your service executable.

    Please "Accept the answer (Yes)" and "share your feedback ". This will help us and others in the community as well.

    Thanks,

    Akshay Kaushik

    0 comments No comments