Ask a Question related to ASP.NET Web Services, Design and Development.
-
Luis Esteban Valencia #1
Hello Error with Web Services. No se puede serializar el miembro System.ComponentModel.MarshalByValueComponent.Site de tipo System.ComponentModel.ISite porque es una interfaz.
Hello I have a solution iwth a web project and web service project I made a
project and I compiled it and it has no errors. But when I try to add the
web reference in the webproject I have this error.
The code of the WebService is this:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
namespace wsPortalProveedores
{
/// <summary>
/// Descripción breve de WSProveedores.
/// </summary>
public class WSProveedores : System.Web.Services.WebService
{
public WSProveedores()
{
//CODEGEN: llamada necesaria para el Diseñador de servicios Web ASP .NET
InitializeComponent();
}
private System.Data.SqlClient.SqlConnection conexion;
#region Código generado por el Diseñador de componentes
//Requerido por el Diseñador de servicios Web
private IContainer components = null;
/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new
System.Configuration.AppSettingsReader();
this.conexion = new System.Data.SqlClient.SqlConnection();
//
// conexion
//
this.conexion.ConnectionString =
((string)(configurationAppSettings.GetValue("Conex ion1", typeof(string))));
}
/// <summary>
/// Limpiar los recursos que se estén utilizando.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
// EJEMPLO DE SERVICIO WEB
// El servicio de ejemplo HelloWorld() devuelve la cadena Hola a todos
// Para generar, quite la marca de comentario de las siguientes líneas y,
después, guarde y genere el proyecto
// Para probar el servicio Web, presione F5
// [WebMethod]
// public string HelloWorld()
// {
// return "Hola a todos";
// }
[WebMethod]
public bool verificar(string usuario, string password)
{
System.Configuration.AppSettingsReader configurationAppSettings = new
System.Configuration.AppSettingsReader();
conexion.ConnectionString =
((string)(configurationAppSettings.GetValue("Conex ion", typeof(string))));
SqlCommand mycmd = new SqlCommand();
mycmd.CommandText = "autenticar";
mycmd.Connection = conexion;
mycmd.CommandType = CommandType.StoredProcedure;
SqlParameter param1 = new SqlParameter();
SqlParameter param2 = new SqlParameter();
param1.Direction = ParameterDirection.Input;
param2.Direction = ParameterDirection.Input;
mycmd.Parameters.Add("@UID", usuario);
mycmd.Parameters.Add("@password", password);
conexion.Open();
SqlDataReader myreader = mycmd.ExecuteReader();
try
{
myreader.Read();
if(myreader.HasRows)
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
conexion.Close();
}
}
[WebMethod]
public DataTable Proveedorenstock(string usuario)
{
SqlDataAdapter sqladp = new SqlDataAdapter("paproveedores1", conexion);
sqladp.SelectCommand.CommandType = CommandType.StoredProcedure;
sqladp.SelectCommand.Parameters.Add("@proveedor", usuario);
conexion.Open();
try
{
DataSet ds = new DataSet();
sqladp.Fill(ds, "Proveedoresenstock");
return ds.Tables["Proveedoresenstock"];
}
catch(Exception ex)
{
throw ex;
}
finally
{
conexion.Close();
}
}
}
}
Error de servidor en la aplicación '/wsPortalProveedores'.
----------------------------------------------------------------------------
----
No se puede serializar el miembro
System.ComponentModel.MarshalByValueComponent.Site de tipo
System.ComponentModel.ISite porque es una interfaz.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual.
Revise el seguimiento de la pila para obtener más información acerca del
error y dónde se originó en el código.
Detalles de la excepción: System.NotSupportedException: No se puede
serializar el miembro System.ComponentModel.MarshalByValueComponent.Site de
tipo System.ComponentModel.ISite porque es una interfaz.
Error de código fuente:
Se ha generado una excepción no controlada durante la ejecución de la
solicitud Web actual. La información sobre el origen y la ubicación de la
excepción pueden identificarse utilizando la excepción del seguimiento de la
pila siguiente.
Seguimiento de la pila:
[NotSupportedException: No se puede serializar el miembro
System.ComponentModel.MarshalByValueComponent.Site de tipo
System.ComponentModel.ISite porque es una interfaz.]
System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type, Boolean
canBePrimitive, MemberInfo memberInfo) +1283
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source, Boolean directReference) +50
System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type, MemberInfo
source)
System.Xml.Serialization.StructModel.GetPropertyMo del(PropertyInfo
propertyInfo)
System.Xml.Serialization.StructModel.GetFieldModel (MemberInfo memberInfo)
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(Struc
tModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(Struc
tModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, Boolean repeats)
+440
[InvalidOperationException: Error al reflejar el tipo
'System.Data.DataTable'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel
model, String ns, ImportContext context, String dataType, Boolean repeats)
+1059
System.Xml.Serialization.XmlReflectionImporter.Imp ortAccessorMapping(MemberM
apping accessor, FieldModel model, XmlAttributes a, String ns, Type
choiceIdentifierType) +8242
System.Xml.Serialization.XmlReflectionImporter.Imp ortMemberMapping(XmlReflec
tionMember xmlReflectionMember, String ns, XmlReflectionMember[]
xmlReflectionMembers) +795
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
+300
[InvalidOperationException: Error al reflejar 'ProveedorenstockResult'.]
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(XmlRefle
ctionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement)
+607
System.Xml.Serialization.XmlReflectionImporter.Imp ortMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement) +108
System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflecti
onImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle
paramStyle, String elementName, String elementNamespace, Boolean
nsIsDefault, XmlReflectionMember[] members, Boolean validate) +169
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +2860
[InvalidOperationException: No se puede reflejar el método
WSProveedores.Proveedorenstock.]
System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs) +5415
System.Web.Services.Description.SoapProtocolReflec tor.ReflectMethod()
+130
System.Web.Services.Description.ProtocolReflector. ReflectBinding(ReflectedBi
nding reflectedBinding) +1818
System.Web.Services.Description.ProtocolReflector. Reflect() +506
System.Web.Services.Description.ServiceDescription Reflector.ReflectInternal(
ProtocolReflector[] reflectors) +495
System.Web.Services.Description.ServiceDescription Reflector.Reflect(Type
type, String url) +112
System.Web.Services.Protocols.DocumentationServerT ype..ctor(Type type,
String uri) +158
System.Web.Services.Protocols.DocumentationServerP rotocol.Initialize()
+269
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +106
[InvalidOperationException: No se puede administrar la solicitud.]
System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&
abortProcessing) +205
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +82
[InvalidOperationException: No se pudo administrar la solicitud.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type
type, HttpContext context, HttpRequest request, HttpResponse response) +154
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContex
t context, String verb, String url, String filePath) +94
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig) +699
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep
..Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +173
----------------------------------------------------------------------------
----
Información de versión: Versión de Microsoft .NET Framework:1.1.4322.573;
Versión de ASP.NET:1.1.4322.573
--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
Luis Esteban Valencia Guest
-
System.ComponentModel.Win32Exception: Access is denied
Hi, From a web application using following code iam executing an EXE. IPTCProcessInfo.FileName = "C:\\IMGExtractor.exe"; ... -
System.ComponentModel.Design.ArrayEditor - How to
I have a custom control which is a set of tab images like in hotmail. In my control I have a hard coded array that sets the string value of the... -
Finding a Component's (ComponentModel.Component) Parent Form
I'm working on a .net component (not a control) and need to find out what form the component is contained in during runtime (DesignMode=False). ... -
System.Net.WebException occurred in system.web.services.dll - HTTP status 405: Method not allowed.
Hi, Have anyone ever encountered an exception error: The request failed with HTTP status 405: Method not allowed when trying to remotely invoke a... -
Significance of System.ComponentModel, IComponent, etc.
Hi. I'm looking for in-depth resources on the use of the System.ComponentModel namespace, namely the Component class and the IComponent interface.... -
Sami Vaaraniemi #2
Re: Hello Error with Web Services. No se puede serializar el miembro System.ComponentModel.MarshalByValueComponent.Site de tipo System.ComponentModel.ISite porque es una interfaz.
My Spanish (?) is really rusty but I think the problem is that you are
trying to return a DataTable from a web method. This will not work, you will
have to return a DataSet containing your DataTable instead. See
[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;306134[/url].
Regards,
Sami
"Luis Esteban Valencia" <luisvalen@haceb.com> wrote in message
news:OtgQm9puEHA.2520@TK2MSFTNGP15.phx.gbl...a> Hello I have a solution iwth a web project and web service project I madetypeof(string))));> project and I compiled it and it has no errors. But when I try to add the
> web reference in the webproject I have this error.
>
> The code of the WebService is this:
> using System;
>
> using System.Collections;
>
> using System.ComponentModel;
>
> using System.Data;
>
> using System.Diagnostics;
>
> using System.Web;
>
> using System.Web.Services;
>
> using System.Data.SqlClient;
>
> namespace wsPortalProveedores
>
> {
>
> /// <summary>
>
> /// Descripción breve de WSProveedores.
>
> /// </summary>
>
> public class WSProveedores : System.Web.Services.WebService
>
> {
>
> public WSProveedores()
>
> {
>
> //CODEGEN: llamada necesaria para el Diseñador de servicios Web ASP .NET
>
> InitializeComponent();
>
> }
>
> private System.Data.SqlClient.SqlConnection conexion;
>
> #region Código generado por el Diseñador de componentes
>
>
> //Requerido por el Diseñador de servicios Web
>
> private IContainer components = null;
>
>
> /// <summary>
>
> /// Método necesario para admitir el Diseñador. No se puede modificar
>
> /// el contenido del método con el editor de código.
>
> /// </summary>
>
> private void InitializeComponent()
>
> {
>
> System.Configuration.AppSettingsReader configurationAppSettings = new
> System.Configuration.AppSettingsReader();
>
> this.conexion = new System.Data.SqlClient.SqlConnection();
>
> //
>
> // conexion
>
> //
>
> this.conexion.ConnectionString =
> ((string)(configurationAppSettings.GetValue("Conex ion1",-->
> }
>
> /// <summary>
>
> /// Limpiar los recursos que se estén utilizando.
>
> /// </summary>
>
> protected override void Dispose( bool disposing )
>
> {
>
> if(disposing && components != null)
>
> {
>
> components.Dispose();
>
> }
>
> base.Dispose(disposing);
>
> }
>
>
> #endregion
>
> // EJEMPLO DE SERVICIO WEB
>
> // El servicio de ejemplo HelloWorld() devuelve la cadena Hola a todos
>
> // Para generar, quite la marca de comentario de las siguientes líneas y,
> después, guarde y genere el proyecto
>
> // Para probar el servicio Web, presione F5
>
> // [WebMethod]
>
> // public string HelloWorld()
>
> // {
>
> // return "Hola a todos";
>
> // }
>
> [WebMethod]
>
> public bool verificar(string usuario, string password)
>
> {
>
> System.Configuration.AppSettingsReader configurationAppSettings = new
> System.Configuration.AppSettingsReader();
>
> conexion.ConnectionString =
> ((string)(configurationAppSettings.GetValue("Conex ion", typeof(string))));
>
> SqlCommand mycmd = new SqlCommand();
>
> mycmd.CommandText = "autenticar";
>
> mycmd.Connection = conexion;
>
> mycmd.CommandType = CommandType.StoredProcedure;
>
> SqlParameter param1 = new SqlParameter();
>
> SqlParameter param2 = new SqlParameter();
>
> param1.Direction = ParameterDirection.Input;
>
> param2.Direction = ParameterDirection.Input;
>
> mycmd.Parameters.Add("@UID", usuario);
>
> mycmd.Parameters.Add("@password", password);
>
> conexion.Open();
>
> SqlDataReader myreader = mycmd.ExecuteReader();
>
> try
>
> {
>
> myreader.Read();
>
> if(myreader.HasRows)
>
> {
>
> return true;
>
> }
>
> else
>
> {
>
> return false;
>
> }
>
> }
>
> catch(Exception ex)
>
> {
>
> throw ex;
>
> }
>
> finally
>
> {
>
> conexion.Close();
>
> }
>
> }
>
> [WebMethod]
>
> public DataTable Proveedorenstock(string usuario)
>
> {
>
> SqlDataAdapter sqladp = new SqlDataAdapter("paproveedores1", conexion);
>
> sqladp.SelectCommand.CommandType = CommandType.StoredProcedure;
>
> sqladp.SelectCommand.Parameters.Add("@proveedor", usuario);
>
> conexion.Open();
>
> try
>
> {
>
> DataSet ds = new DataSet();
>
> sqladp.Fill(ds, "Proveedoresenstock");
>
> return ds.Tables["Proveedoresenstock"];
>
> }
>
> catch(Exception ex)
>
> {
>
> throw ex;
>
> }
>
> finally
>
> {
>
> conexion.Close();
>
> }
>
>
> }
>
> }
>
> }
>
>
>
> Error de servidor en la aplicación '/wsPortalProveedores'.
> --------------------------------------------------------------------------> ----
>
> No se puede serializar el miembro
> System.ComponentModel.MarshalByValueComponent.Site de tipo
> System.ComponentModel.ISite porque es una interfaz.
> Descripción: Excepción no controlada al ejecutar la solicitud Web actual.
> Revise el seguimiento de la pila para obtener más información acerca del
> error y dónde se originó en el código.
>
Sami Vaaraniemi Guest



Reply With Quote

