locked
System.TypeInitializationException: 'The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Database' threw an exception.' RRS feed

  • Question

  • User-930371450 posted

    Hi Team,

    I am using this namespace using Microsoft.Practices.EnterpriseLibrary.Data; to connect the database.

    public static Database CreateDatabase(string connectionString,bool isEncrypted=false)
    {
    try
    {
    string decryptedConnectionString;
    if (isEncrypted)
    {
    decryptedConnectionString = DecryptConnectionString(connectionString);
    }
    else
    {
    decryptedConnectionString = connectionString;
    }
    Database database = new SqlDatabase(decryptedConnectionString);
    return database;
    }
    catch(Exception ex)
    {
    throw new Exception("Error reading database details. Error:" + ex.Message);
    }
    }

    At this line Database database = new SqlDatabase(decryptedConnectionString);, I am getting below exception.

    I am using Asp.Net core 3.0 Web API

    System.TypeInitializationException: 'The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Database' threw an exception.'

    FileNotFoundException: Could not load file or assembly 'System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

    Sunday, April 19, 2020 6:14 PM

All replies