vb.net 无法导入`导入 System.Web.Script.Serialization`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15605048/
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
Cannot import `Imports System.Web.Script.Serialization`
提问by Skilo Skilo
When I try to Imports System.Web.Script.Serialization, I get an error in VB 2010 that says:
当我尝试时Imports System.Web.Script.Serialization,我在 VB 2010 中收到一条错误消息:
Warning: Namespace or type specified in the Imports
System.Web.Script.Serializationdoesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
警告:导入
System.Web.Script.Serialization中指定的命名空间或类型不包含任何公共成员或无法找到。确保命名空间或类型已定义并且至少包含一个公共成员。确保导入的元素名称不使用任何别名。
Not sure why I can't import it.
不知道为什么我不能导入它。
回答by stakx - no longer contributing
You might be missing an assembly reference to System.Web.Extensions.dll. Add this reference to your project, then try again.
您可能缺少对System.Web.Extensions.dll. 将此引用添加到您的项目,然后重试。
Generally speaking, when you encounter this issue, go to the .NET API reference page of the type you want to use — for instance, JavaScriptConverter— and look out for the Namespace and Assembly hints (make sure you're looking at the page for the .NET framework version that you are using):
一般来说,当您遇到此问题时,请转至您要使用的类型的 .NET API 参考页面——例如JavaScriptConverter——并查看命名空间和程序集提示(确保您正在查看该页面以了解您正在使用的 .NET 框架版本):


- Namespace:tells you what to put in the
Importsdirective. - Assembly:tells you what assembly you need to reference in your project (e.g. go to Solution Explorer, locate References, and select Add Reference…from the context menu).
- 命名空间:告诉你在
Imports指令中放置什么。 - 程序集:告诉您需要在项目中引用哪个程序集(例如,转到“解决方案资源管理器”,找到“引用”,然后从上下文菜单中选择“添加引用...”)。
回答by user700390
Also make sure to check the "Target Framework" in the project properties. If you are targeting a "Client Profile" framework then the assembly System.Web.Extensions.dll will not be available to add as a reference to your project.
还要确保检查项目属性中的“目标框架”。如果您的目标是“客户端配置文件”框架,那么程序集 System.Web.Extensions.dll 将无法添加为您的项目的引用。

