How to find correct "System.Data.SqlServerCe.dll" in desktop project?


  • Hi,
      I am working on a .dll which need to access .sdf ( sql server mobile db). In my project, I added a reference "System.Data.SqlServerCe.dll". The dll is located in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE.
    I am able to compile the project. Then I created a Unit project for this dll file. In Unit project, I added the same reference.
    Now the magic things happen. The compiling was failed. I got "Error    1    The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    C:\VS2005\MobileDB\UnitMobileDBProject\UnitMobileDB.cs    50    13    UnitMobileDBProject".

    I don't understand how come the same .dll could pass in a dll project but failed in unit test project. And I never saw the System.Data.SqlServerCe display in ".Net" Section of Add reference. But in my office, I installed same version of VS2005 for software tester. I could see the System.Data.SqlServerCe display in the ".Net" section of Add Reference.

    Please help me to fix this problem. Thanks.
    Saturday, February 02, 2008 3:06 AM


All replies

  • Make sure both systems are fully up to date with VS 2005 SP1 and SQL Compact 3.1. See this blog entry for detailed guidance:


    Saturday, February 02, 2008 11:06 AM
  • The reason you are not seeing a Reference Entry for SqlCe must be because you don't have dev tools installed on your machine. The link Eric Posted, the third point talks about that and it takes you to following link:


    After this the SqlCe dll in your visual studio directory will be updated and you will also see the reference for the same.

    Tuesday, February 05, 2008 10:01 AM
  • I have the exact same error in an application targeted for a CE device.

    The program is written by a "Vendor A" for my customer.   I "Vendor B" must be able to rebuild and support the application for the same customer.   Vendor A, built the application under Visual Studio 2005, and I am using Visual Studio Team System 2008 with SP1.

    I built the application fine, and deployed to the CE device, but got exception errors as soon as and SQL CE command were used.  ( I did not debug to the exact statement ).

    Source code is C# - Framework is 2.0.  We want to keep the application at .NET 2.0 as that is the version already embedded on the device.
    I downloaded SQL CE 3.1 and installed.   I removed the reference to :
    c:\Program Files\Microsoft SQL Server Compact Edition\v3.5\System.Data.SqlServerCe.dll
    and replaced it with
    c:\Program Files\Microsoft SQL Server Compact Edition\v3.1\System.Data.SqlServerCe.dll

    Thinking this is all I had to do, I performed a clean build and got the above error.
    I also got 3 additional errors:
    The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=,    
    The type 'System.ComponentModel.IListSource' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=,        
    The type 'System.Data.Common.DbDataReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=,    

    The module does include the following using statements:
        using System;
        using System.Collections;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Data.SqlServerCe;                                                                                                    

    System.Data is C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\System.Data.dll   Version 2.0

    Friday, April 16, 2010 7:36 PM
  • You should change the reference to point to: C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\SDK\bin\wce500\System.Data.SqlServerCe.dll.

    If that folder is not there, install: Erik Ejlskov Jensen - Please mark as answer, if this was it.
    Saturday, April 17, 2010 9:50 AM
  • for those using .net 3.5 or higher , one should look for System.Data.SqlServerCe.dll

    that can be found in default install directory: C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop

    unless one has a more recent release of compact sql server and need to use that later version
    • Edited by fs - ab Thursday, September 22, 2011 9:46 PM
    Thursday, September 22, 2011 9:45 PM