.net core to sqlserverce issue

  • Thread starter Thread starter varsha raja
  • Start date Start date
V

varsha raja

Guest
Am trying to connect sqlserverce(.sdf) file using .net core console. But am keep on getting the below error. Whereas the same code working properly in .net framework. Can any one suggest me what is the issue.

The type initializer for 'System.Data.SqlServerCe.KillBitHelper' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Permissions

Below is my code, as soon as the debugger enter sqlceconnection it is throwing the above erro.

string constring = @"Data Source = C:\Test.sdf";
SqlCeConnection conn = new SqlCeConnection(constring);
DataTable dTable = new DataTable();
conn.Open();
SqlCeCommand cmd = new SqlCeCommand("SELECT [Type],[Key],[Data] FROM table", conn);
SqlCeDataAdapter dAdapter = new SqlCeDataAdapter(cmd);
dAdapter.Fill(dTable);

Continue reading...
 
Back
Top