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.
I'm pretty sure you need to drop to ASP.NET Core 2.1 to use Enterprise Library 6. ASP.NET 3.0 is not compatible with .NET Framework and it appears Enterprise library is no longer supported.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
60 Points
311 Posts
System.TypeInitializationException: 'The type initializer for 'Microsoft.Practices.EnterpriseLib...
Apr 19, 2020 06:14 PM|SSK_Nani|LINK
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.
All-Star
53001 Points
23596 Posts
Re: System.TypeInitializationException: 'The type initializer for 'Microsoft.Practices.Enterpris...
Apr 19, 2020 06:18 PM|mgebhard|LINK
I'm pretty sure you need to drop to ASP.NET Core 2.1 to use Enterprise Library 6. ASP.NET 3.0 is not compatible with .NET Framework and it appears Enterprise library is no longer supported.
https://github.com/Chavoshi/EnterpriseLibrary.NetCore
Contributor
2070 Points
606 Posts
Re: System.TypeInitializationException: 'The type initializer for 'Microsoft.Practices.Enterpris...
Apr 20, 2020 09:05 AM|Sherry Chen|LINK
Hi SSK_Nani ,
From the link mgebhard provided, it seems that ASP.NET Core 3.0 does not support Enterprise library .
For your issue, it is more related with Enterprise Library which is a third party product, I would suggest you submit your issue for more help below:
https://github.com/Chavoshi/EnterpriseLibrary.NetCore/issues
Best Regards,
Sherry
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.