简体   繁体   English

读取 Azure 密钥保管库会引发异常:System.ExecutionEngineException:“引发了‘System.ExecutionEngineException’类型的异常。”

[英]Reading Azure key vault throws exception: System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'

I am trying to read the values from Azure Key vault using below code, but it always throws below exception at first time and second time it just runs fine.我正在尝试使用以下代码从 Azure 密钥库中读取值,但它总是第一次抛出异常,第二次运行正常。 As it is System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'因为它是System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.' No way to handle it(at least I am aware).没有办法处理它(至少我知道)。

My code looks like:我的代码如下所示:

private Dictionary<string, string> GetCredentials()
    {

        string tenantId =  "<TenantId>";
        string clientId = "<ClientId>";
        string clientSecret = "<ClientSecret>";
        string vaultUrl ="<VaultUrl>";

        SecretClient secretClient = new SecretClient(
            new Uri(vaultUrl), 
           new ClientSecretCredential(tenantId, clientId, clientSecret)
        );

        var UserName = secretClient.GetSecret("UserName");
        var Password = secretClient.GetSecret("Password");
        var result = new Dictionary<string, string>
        {
            {UserName.Value.Value, Password.Value.Value}
        };
        return result;
    }

We cannot exactly say that this exception is thrown while accessing the azure key vault.我们不能准确地说是在访问 azure 密钥保管库时引发了此异常。 Because, System.ExecutionEngineException is thrown when there is an issue in CLR.因为,当 CLR 出现问题时,会引发System.ExecutionEngineException might be an error that happen before.可能是之前发生的错误。 The only solution i see is to refactor your code from the starting point to this point(where you access key vault).我看到的唯一解决方案是将代码从起点重构到这一点(访问密钥库的位置)。 You can have an in-depth understanding about the issue over here你可以在这里深入了解这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找到 System.ExecutionEngineException 异常的来源 - How to find source of System.ExecutionEngineException Exception 抛出System.ExecutionEngineException - System.ExecutionEngineException being thrown XXX.exe中发生了未处理的“System.ExecutionEngineException”类型异常 - An unhandled exception of type 'System.ExecutionEngineException' occurred in XXX.exe 为什么此代码抛出System.ExecutionEngineException - Why this code throws System.ExecutionEngineException DirectWriteForwarder.dll 中发生异常“System.ExecutionEngineException” - Exception 'System.ExecutionEngineException' occurred in DirectWriteForwarder.dll 给定System.ExecutionEngineException的GetMessage() - GetMessage() given an System.ExecutionEngineException DBContext 构造函数中的 System.ExecutionEngineException - System.ExecutionEngineException in DBContext Constructor Windows服务的System.ExecutionEngineException - System.ExecutionEngineException With Windows Service 沉默“未知模块中出现类型&#39;System.ExecutionEngineException&#39;的未处理异常”错误 - Silencing “An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module” error 加载嵌入式DLL时引发System.ExecutionEngineException - System.ExecutionEngineException thrown when loading embedded DLL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM