I'm currently programming a small application for Windows Mobile 5.0 and .NET Compact Frameword 2.0 including SQL Server Compact Edition.
The following code unfortunately does not for compiling.
38 SqlCeEngine engine = new SqlCeEngine("Data Source = 'test.sdf'");
39 engine.CreateDatabase();
40
41 System.Data.SqlServerCe.SqlCeConnection ssceconn = new SqlCeConnection("Data Source = 'test.sdf'");
42 ssceconn.Open();
There's no more code inside the project except the standard code für a blank Form. I'm getting the following error when i try to compile:
Zeile 41: Der Typ System.Data.Common.DbConnection ist in einer Assembly, auf die nicht verwiesen wird, definiert. Fügen Sie einen Verweis zur Assembly System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 hinzu. (CS0012)
For all those who don't understand german: The Type System.Data.Common.DBConnection is in an assembly for which there isn't a reference defined. Please add a reference for System.Data, Version 2.0.0.0, Culture=....
I already have a reference on System.Data inside my project, and the version, culture and the publickeytoken are the same as required by the compiler... I'm getting really hopeless, does anybody have an idea? Thanks a lot in advance!!
By the way: My system: .NET Framework 1.1, 2.0 and 3.0 as well as .NET Compact Framework 2.0 and .NET Framework SDK v2.0. Also there is MS SQL Server Compact Edition 3.1 and SQL Server CE 3.1 SDK installed (all in german). My OS is Windows XP SP2, all updates are done and I'm using SharpDevelop 2.1.0.
You need to add a reference to the SQLCe engine (system.data.SqlServerCe) in your project. If you create a new Data Connection in the Server Explorer in Visual Studio, and use it to build a Data Source, the path of the needed DLL will be added to your project. On my system it's located at C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\System.Data.SqlServerCe.dll.
I discuss the details of this in my EBook.
hth
|||Thanks a lot for your answer!
I found the "error" myself, or at least a solution for this problem. It was not because of the missing reference to the system.data.SqlServerCe, because I already added this reference before and compiling didn't work. I just removed all the references from my project and added them manually, referencing not the files in the GAC but selecting them from the .net framework sdk-folder/compact framework (As I can rememember it is something like: C:\Programme\Microsoft .NET\.Net Framework SDK\Compact Framework\....). Don't ask me why it works this way, but i'm able to compile now and everything works fine. Is it possible that the versions of the referenced assemblies in the GAC are not for the compact framework?
No comments:
Post a Comment