none
Component Services: COM+ , MySql, WebServices RRS feed

  • Pregunta


  • Que tal, es la primera vez que posteo y espero que me puedan ayudar con un problema. LLevo un par de dias queriendo crear un servicio en el component services, en visual 6 era muy sencillo pero ahora me esta dando demasiados problemas y solo quiero hacer uso del object pooling. Mi aplicacion es sencilla, una libreria de conexion con mysql, unas clase que contiene metodos de consulta, ingreso, edicio y borrado con la clase de conexion y un servicio web llama a la misma para mostrar los resultados.

    Queria crear el COM+ que encapsule unicamente la libreria de conexion; lo creo y no hay problema con metodos sencillos pero los importantes, connect y desconnect, no funcionan. Me sale This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.

    at System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(IMethodCallMessage reqMcmMsg, Boolean useDispatchMessage, Int32 callType)
       at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(IMessage reqMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.Data.Odbc.OdbcConnection.SetStateExecuting(String method, OdbcTransaction transaction)
       at System.Data.Odbc.OdbcCommand.ValidateConnectionAndTransaction(String method)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
       at System.Data.Odbc.OdbcCommand.ExecuteScalar()
       at MD_DBProcess.CompanySequenceType(Int32 cpnyId) in C:\Documents and Settings\wise\My Documents\Visual Studio 2005\WebSites\WebServices\App_Code\MD_DBProcess.vb:line 1124

    Mi libreria es sencilla, y me guie por algunos articulos

    http://www.devsource.com/c/a/Using-VS/Designing-COM-Applications-with-a-Web-Service-Appeal/
    http://www.15seconds.com/issue/030501.htm

    Imports System.Data
    Imports System.Data.Odbc
    Imports System.EnterpriseServices

    <Assembly: ApplicationName("MySQLService")>
    <Assembly: ApplicationActivation(ActivationOption.Server)>
    <Assembly: ApplicationAccessControl(System.EnterpriseServices.AccessChecksLevelOption.ApplicationComponent)>
    <Assembly: CompensatingResourceManager.ApplicationCrmEnabled(True)>

    Namespace WiseMySql

        Public Interface IMySqlClient

            Sub Connect(ByVal db As String, ByVal usr As String, ByVal psw As String)

            Sub Disconnect()

            Sub DB_Credentials(ByVal cpny As String, ByRef db As String, ByRef usr As String, ByRef psw As String)

            Function AddParameter(ByVal procedure As String, ByVal parameter As String) As String

            Function MakeSQL(ByVal parameter As String) As String

            Function BoolToBinary(ByVal parameter As Boolean) As String

        End Interface

        <JustInTimeActivationAttribute(True), Synchronization(SynchronizationOption.Required), Transaction(System.EnterpriseServices.TransactionOption.Supported), EventTrackingEnabled(True), ObjectPooling(MinPoolSize:=1, MaxPoolSize:=100, CreationTimeout:=5000)> _
        Public Class MD_MySqlClient
            Inherits ServicedComponent
            Implements IMySqlClient

            Protected Friend conn_str_ As String
            Protected Friend mssg_ As String
            Protected Friend conn_ As OdbcConnection

            Public Property ConnStr() As String
                Get
                    Return Me.conn_str_
                End Get
                Set(ByVal value As String)
                    Me.conn_str_ = value
                End Set
            End Property

            Public Property Mssg() As String
                Get
                    Return Me.mssg_
                End Get
                Set(ByVal value As String)
                    Me.mssg_ = value
                End Set
            End Property

            Public Property Conn() As OdbcConnection
                Get
                    Return Me.conn_
                End Get
                Set(ByVal value As OdbcConnection)
                    Me.conn_ = value
                End Set
            End Property

            Public Sub New()
                MyBase.New()
                Me.Mssg = ""
                Me.ConnStr = ""
                Me.Conn = New OdbcConnection()
            End Sub

            Public Sub Connect(ByVal db As String, ByVal usr As String, ByVal psw As String) Implements IMySqlClient.Connect

                ' Return this object to the pool after use.
                ContextUtil.DeactivateOnReturn = False

                'If Me.Conn.State < 1 Then
                Me.Conn = New OdbcConnection()            'Variable de conexion
                'End If

                Me.ConnStr = "Driver={MySQL ODBC 3.51 Driver};Server=MiServidor;Database=" + db + "; User=" + usr + ";Password=" + psw + ";Option=3;" 'String de conexion
                Me.Conn.ConnectionString = Me.ConnStr
                Try
                    Me.Conn.Open()
                Catch ex As Exception
                    Me.Mssg = "Error : " + ex.Message
                End Try

            End Sub

            Public Sub Disconnect() Implements IMySqlClient.Disconnect

                ' Return this object to the pool after use.
                ContextUtil.DeactivateOnReturn = True

                If Me.Conn.State <> ConnectionState.Closed And Me.Conn.State <> ConnectionState.Broken Then
                    Try
                        Me.Conn.Close()
                    Catch ex As Exception
                        Me.Mssg = "Error : " + ex.Message
                    End Try
                End If

            End Sub

            Public Sub DB_Credentials(ByVal cpny As String, ByRef db As String, ByRef usr As String, ByRef psw As String) Implements IMySqlClient.DB_Credentials

                'Aqui retorno los campos de usuario, clave y la base, de acuerdo a lo requerido por el usuario, esto si vale

            End Sub

            Public Function AddParameter(ByVal procedure As String, ByVal parameter As String) As String Implements IMySqlClient.AddParameter
                Dim ret As String = ""

                ret = procedure
                If Not ret.Contains("(") Then
                    ret = String.Concat(ret, "(" + parameter + ")")
                Else
                    ret = ret.Replace(")", ",")
                    ret = String.Concat(ret, parameter + ")")
                End If

                Return ret
            End Function

            Public Function MakeSQL(ByVal parameter As String) As String Implements IMySqlClient.MakeSQL
                Dim ret As String = ""

                ret = "'" + parameter + "'"

                Return ret
            End Function

            Public Function BoolToBinary(ByVal parameter As Boolean) As String Implements IMySqlClient.BoolToBinary
                Dim ret As String = ""

                If parameter Then
                    ret = "1"
                Else
                    ret = "0"
                End If

                Return ret
            End Function

            ''' <summary>
            ''' Overriding for COM+ Usage
            ''' </summary>
            Protected Overrides Sub Activate()
                'Activate Component
            End Sub

            Protected Overrides Sub Deactivate()
                'Deactivate Component
            End Sub

            Protected Overrides Function CanBePooled() As Boolean
                Return True 'This Object can be pooled
            End Function

        End Class

    End Namespace

    Este error solo se da con los metodos que conectan a la base. Cualquier ayuda me serviria mucho! Gracias.

    miércoles, 15 de octubre de 2008 19:39