C# 找不到命名空间“System.Data.SqlServerCe”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11493674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 18:03:23  来源:igfitidea点击:

Cannot find namespace 'System.Data.SqlServerCe'

c#asp.netvisual-studio-2008sql-server-ce

提问by Hyman

I did include the System.Data.SqlServerCedll, put using System.Data.SqlServerCe;in my code, but when I open the .NET page I get:

我确实包含了System.Data.SqlServerCedll,放入using System.Data.SqlServerCe;了我的代码中,但是当我打开 .NET 页面时,我得到:

The type or namespace name 'SqlServerCe' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

命名空间“System.Data”中不存在类型或命名空间名称“SqlServerCe”(您是否缺少程序集引用?)

I have nave no idea how to fix this. Thanks in advance.

我不知道如何解决这个问题。提前致谢。

采纳答案by Shiham

This can be solved confirming following 2 points:

这可以通过确认以下两点来解决:

  1. Check whether you already have System.Data.SqlServerCenamespace added to the Referencesfolder of your application. If its not there you may right click the References folder and select Add referencesoption. From the popup window go to .Net taband select System.Data.SqlServerCefrom the list and click OK to add the namespace to the project.
  2. If you are OK with step 1, add using System.Data.SqlServerCe;to the top of your code behind file which uses the System.Data.SqlServerCe namespace.
  1. 检查是否已将System.Data.SqlServerCe命名空间添加到应用程序的References文件夹中。如果它不存在,您可以右键单击“引用”文件夹并选择“添加引用”选项。从弹出窗口转到.Net 选项卡System.Data.SqlServerCe从列表中选择 并单击确定将命名空间添加到项目中。
  2. 如果您对第 1 步没问题,请将其添加using System.Data.SqlServerCe;到使用 System.Data.SqlServerCe 命名空间的代码隐藏文件的顶部。

回答by Anirudh Ramanathan

Check your web.configfile for any reference to that, and correct it. It could be an alias you defined wrong.

检查您的web.config文件是否有任何参考,并更正它。它可能是您定义错误的别名。

This answermight solve your issue.

这个答案可能会解决您的问题。

回答by Pogrindis

Installing SQL Compact Server and then adding that reverence system.data.SqlServerCe.dll directly from your Microsoft Compact DataBase/ Program folder.

安装 SQL Compact Server,然后直接从 Microsoft Compact DataBase/Program 文件夹中添加系统.data.SqlServerCe.dll。

You're missing the dll.

你缺少dll。

Im sure you already figured this one out though.

我相信你已经想通了这一点。

回答by Jazimov

If you have an existing reference to System.Data.SqlServerCeyet you see a yellow symbolnext to itthen you should:

如果您有一个现有的参考,System.Data.SqlServerCe您会在它旁边看到一个黄色符号那么您应该:

  • Remove the reference by right-clicking it.
  • Re-Add the reference.
  • 通过右键单击引用来删除引用。
  • 重新添加引用。

To Re-Add:Right click the References folder and select Add Reference... option. Go to the Assemblies | Framework option on the left pane, then scroll to System.Data.SqlServerCein the right pane. If it's there, click it then be sure to check the checkbox next to it before clicking OK.

重新添加:右键单击“引用”文件夹并选择“添加引用...”选项。前往大会 | 左侧窗格中的框架选项,然后滚动到System.Data.SqlServerCe右侧窗格中。如果它在那里,请单击它,然后确保在单击“确定”之前选中它旁边的复选框。

If System.Data.SqlServerCeis not in the list then you're going to have to browse for it on your computer. To do that, click the Add Reference... dialog's Browse... button and try looking in this folder:

如果System.Data.SqlServerCe不在列表中,那么您将不得不在计算机上浏览它。为此,请单击“添加引用...”对话框的“浏览...”按钮并尝试在此文件夹中查找:

C:\Program Files\Microsoft SQL server Compact edition\v3.5\Desktop

or

或者

C:\Program Files\Microsoft SQL server Compact edition\v4.0\Desktop

(The v#.# value in the examples above might be different by the time you read this, so navigate first to C:\Program Files\Microsoft SQL server Compact edition\then choose the latest version or a specific version if you know what that should be.)

(在您阅读本文时,上述示例中的 v#.# 值可能会有所不同,因此请先导航到C:\Program Files\Microsoft SQL server Compact edition\然后选择最新版本或特定版本(如果您知道应该是什么)。)

Once you find it by browsing, select the System.Data.SqlServerCe.dllfile and OK your way out then try recompiling.

通过浏览找到它后,选择该System.Data.SqlServerCe.dll文件并确定退出,然后尝试重新编译。

回答by Jazimov

This is pretty late for answer. But I also faced the same kind of problem.
I am using Visual Studio 2012and Visual Studio 2017and I found the System.Data.SqlServerCehere.
The same directory for both Versions.

这已经很晚了。但我也面临同样的问题。
我正在使用Visual Studio 2012Visual Studio 2017,我在这里找到了System.Data.SqlServerCe
两个版本的目录相同。

I edited @JesiMov Answer.

我编辑了@JesiMov 答案。

Right click the Referencesfolder and select Add Reference...option.
Go to the Assemblies| Extensionsoption on the left pane, then scroll to System.Data.SqlServerCe in the right pane.

右键单击“引用”文件夹并选择“添加引用...”选项。
前往大会| 左窗格中的扩展选项,然后滚动到右窗格中的 System.Data.SqlServerCe。