Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>