WinCE7 0xc0000005 Native exception on Execute reader

1.8k views Asked by At

I am developing a simple application for Motorola MC32N0 on WinCE7.0 using VS2008 SP1 having .net Compact Framework 3.5 and SQL Server CE 3.5SP1.

Whenever I try to read from database I get this error.

A native exception has occurred in projectName.exe. Select Quit and then restart this program or select details for more information.

When I go to details I get this

ExceptionCode: 0xc0000005
ExceptionAddress: 0xc0000000
Reading: 0xc0000000
at NativeMethods.GetKeyInfo(IntPtrpTx, String pwszBase Table, IntPtr prgDbKeyInfo, Int32 cDbKeyInfo,IntPtr pError)
at SqlCeDataReader.FillMetaData(SqlCeDataReader reader, Int32 resultType) . . .

it continues. This is the database read code

public List<Users> SelectByUserName(string UserName)
{
    var list = new List<Users>();
    using (var command = EntityBase.CreateCommand(Transaction))
    {
        if (UserName != null)
        {
            command.CommandText = "SELECT * FROM Users WHERE UserName=@UserName";
            command.Parameters.Add("@UserName", SqlDbType.NVarChar);
            command.Parameters["@UserName"].Value = UserName;
        }
        else
            command.CommandText = "SELECT * FROM Users WHERE UserName IS NULL";

        using (var reader = command.ExecuteReader())
        {
            list = fetchData(reader);
        }
    }
    return list;
}

When it reaches this command.ExecuteReader() the exception occurs.

After a lot of searching some guys are saying that this might be a mismatch of the SQL Server CE version but how do I fix that? One file is copied to folder when application is deployed. How to check it's version or change the version of SQL Server CE being used?

1

There are 1 answers

0
Ali Umair On BEST ANSWER

At last after a lot of googling i solved this problem by installing the SP2 for SQL Server CE 3.5, these are the packages Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Mobile & Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop

After installing these remove the reference to System.Data.SqlServerCe and again add the same reference this time with version 3.5.1.0. The file is at C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Devices\System.Data.SqlServerCe.dll and version shown is windows explorer is 3.5.8080.0