Exception: type initializer for 'system.data.sqlclient.sqlconnection'?

后端 未结 12 912
悲哀的现实
悲哀的现实 2020-12-11 02:35

I couldn\'t figure out what is the problem for this exception.

The type initializer for \'System.Data.SqlClient.SqlConnection\' threw an exception

12条回答
  •  借酒劲吻你
    2020-12-11 03:03

    If you have a project that contains the NuGet packages for both Oracle and SQL Server, this solution might help you fix this error.

    Uninstall both of these NuGet packages:

    • Oracle.ManagedDataAccess.Core
    • System.Data.SqlClient

    Open your app.config and check if you still have have any dependent assembly entries listed. If you do, delete those entries now. They might look something like this:

    
        
        
    
    
        
        
    
    

    While still in your app.config file, delete the entire Oracle Managed Data Access section if it exists (This might be the only thing that you need to do to fix this problem, however we performed all of the steps listed in this solution). If you have it, it might look something like this:

    
        
          
              
          
          
            
          
        
    
    

    Open the packages.config file and double check to ensure that the entries for the Oracle and SQL Server packages are not still listed - they should be gone, but it doesn't hurt to be 100% sure.

    Save your project, and then re-add the NuGet packages.

提交回复
热议问题