No se puede encontrar JavaScriptSerializer in.Net 4,0
Parece que no puedo encontrar el JavaScriptSerializer
objeto ni el espacio de nombres System.Web.Script.Serialization
dentro de Visual Studio 2010. Necesito serializar algo a JSON ¿qué se supone que debo usar?
Y sí, ya he incluido el System.Web.Extensions
(en el Sistema.Web.Ampliación.dll) dentro del proyecto. ¿Por eso estoy sorprendido?
- Sé que
System.Web.Extensions
fue marcado como obsoleto en 3.5
12 answers
Compruebe si ha incluido la versión.net 4 de System.Web.Extensions
- también hay una versión 3.5, pero no creo que funcione.
Estos pasos funcionan para mí:
- Crear una nueva aplicación de consola
- Cambie el destino a. net 4 en lugar de Client Profile
- Añadir una referencia a
System.Web.Extensions
(4.0) - Tener acceso a
JavaScriptSerializer
en el Programa.cs now: -)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-19 17:58:00
- Haga clic derecho en
References
y hagaAdd Reference
, luego desdeAssemblies->Framework
seleccioneSystem.Web.Extensions
. - Ahora debería poder agregar lo siguiente a su archivo de clase:
using System.Web.Script.Serialization;
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-13 16:44:23
Desde el primer resultado de búsqueda en Google:
Http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
JavaScriptSerializer Class
Proporciona funcionalidad de serialización y deserialización para aplicaciones habilitadas para AJAX.
Jerarquía de herencia
Sistema.Objeto
Sistema.Web.Script.Serialización.JavaScriptSerializer
Espacio de nombres: Sistema.Web.Script.Serialización
Montaje: Sistema.Web.Extensiones (en Sistema.Web.Ampliación.dll)
Por lo tanto, incluya System.Web.Extensions.dll
como referencia.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-09-11 13:56:03
Estoy usando Visual Studio 2015 y finalmente me encontré con este post.
Sí para utilizar
JavaScriptSerializer json = new JavaScriptSerializer();
Debe hacer clic derecho en referencias y debajo de Ensamblajes choose> Framework choose
System.Web.Extensions
Luego agregue su referencia
using System.Web.Script.Serialization;
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-17 00:44:14
Esta es la forma de obtener JavaScriptSerializer disponible en su aplicación, targetting .NET 4.0
(full)
using System.Web.Script.Serialization;
Esto debería permitirle crear un nuevo objeto JavaScriptSerializer
!
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-09-26 17:24:21
¿Está apuntando al framework. NET 4 o al Perfil de cliente. NET 4?
Si estás apuntando a este último, no encontrarás esa clase. También es posible que le falte una referencia, probablemente a una dll de extensiones.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-09 18:18:45
Para aquellos que parecen estar siguiendo las respuestas anteriores, pero todavía tienen el problema (por ejemplo, ver el primer comentario sobre la pregunta del póster):
Probablemente esté trabajando en una solución con muchos proyectos. El proyecto en el que parece estar trabajando hace referencia a otros proyectos, pero en realidad está modificando un archivo de uno de los otros proyectos. Por ejemplo:
- referencias del proyecto A
System.Web.Extensions
- proyecto A referencias proyecto B
Pero si el archivo es modificar para usar System.Web.Script.Serialization
está en el proyecto B, entonces necesitará agregar una referencia a System.Web.Extension
en el proyecto B también.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-05-02 22:58:15
using System.Web.Script.Serialization;
Está en assembly: System.Web.Extensiones (Sistema.Web.Ampliación.dll)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-07 13:25:53
¿Has incluido una referencia a System.Web.Extensions
? Si hace clic en su primer enlace, dice en qué ensamblaje está.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-09 18:18:59
Hay que añadir la referencia al proyecto.
En las Asambleas, hay un Sistema.Web.Las extensiones Añaden eso.
Una vez hecho esto pon:
using System.Web;
using System.Web.Script;
using System.Web.Script.Serialization;
Eso funcionó para mí.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-02-21 15:51:15
Para que lo sepas, estoy usando Visual Studio 2013 y he tenido el mismo problema hasta que usé las Propiedades del proyecto para cambiar a 3.5 framework y volver a 4.5. Esto por alguna razón registrado el .dll correctamente y podría usar el Sistema .Web.Extensiones.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-29 22:42:42
Puede usar otra opción que es la NewtonsoftJASON, puede instalarla desde el Administrador de paquetes NuGet.Herramientas >> Nuget PacakgeManager
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-16 14:18:22