Hi,
I would like to help you, but please provide more information about
the problem:
Could you please post the complete test of the exception?
Does the Obj object implement the Event interface?
Does the clsid correctly describe the event COM object?
Was the event component installed in COM+ as the event class?
What language is the event class written in?
What OS and Service pack level is this running on?
Thanks,
Slava Gurevich
On Tue, 9 Dec 2003 14:59:09 +0100, "SqlRanger"
[quoted text, click to view] <sqlranger.mvp@mvps.org> wrote:
>I'm using this code to register a LCE transient subscription:
>
>Public Function Add(ByVal Obj As Object) As String
> Dim cat As Object = CreateObject("COMAdmin.COMAdminCatalog")
> Dim Subscriptions As Object = cat.GetCollection("TransientSubscriptions")
> Dim Subscription As Object = Subscriptions.Add()
>
> Subscription.Value("Name") = "TransientSubscription"
> Subscription.Value("EventCLSID") = "{ .. the event CLSID .. }"
> Subscription.Value("SubscriberInterface") = Obj
> Subscriptions.SaveChanges()
>
> Add = Subscription.Key
>
> Marshall.ReleaseComObject(Subscription)
> Marshall.ReleaseComObject(Subscriptions)
> Marahall.ReleaseComObject( cat )
>
>End Function
>
>But a get a COMException "member not fount" at line Subscription.Value("SubscriberInterface") = Obj
>
>Please , could you help me ?
Hi,
try the following:
Subscription.Value("SubscriberInterface") =
Marshal.GetIUnknownForObject(Objeto)
Regards,
Slava Gurevich
On Mon, 15 Dec 2003 10:25:42 +0100, "SqlRanger"
[quoted text, click to view] <sqlranger.mvp@mvps.org> wrote:
>Thank you Slava,
>
>The solution is a very simple test for transient subscriptions.
>
>I Have a project "EventClass". This is the code:
>
>Imports System.EnterpriseServices
>Imports System.Runtime.InteropServices
>
><Guid("57CD98DE-81A5-4a0e-AED9-972428DA26EF")> _
>Public Interface IEventosPedidos
> Sub PedidoRealizado(ByVal IdPedido As Integer)
>End Interface
>
><Guid("DE1D42F4-3538-4d9d-B587-1B5F014D834F"), _
>EventClass(FireInParallel:=True), _
>JustInTimeActivation(True), _
>ObjectPooling(True)> _
>Public Class EventosPedidos
> Inherits ServicedComponent
> Implements IEventosPedidos
>
> Public Sub PedidoRealizado(ByVal IdPedido As Integer) Implements
>IEventosPedidos.PedidoRealizado
> Throw New NotImplementedException("Esta clase debe llamarse por
>medio de eventos COM+")
> End Sub
>End Class
>
>And here is the AssemblyInfo.vb:
>
><Assembly: AssemblyVersion("1.0.0.0")>
><Assembly: AssemblyKeyFile("c:\eidos.snk")>
><Assembly: ApplicationName("EventosPedidos")>
><Assembly: ApplicationActivation(ActivationOption.Server)>
><Assembly: ApplicationAccessControl(False)>
>
>I have generated this project, put the assembly into the GAC and registered
>it into COM+ using RegSvcs.exe
>
>I also have a project "Subscriptor". And here is the code:
>
>Imports System.EnterpriseServices
>
>Public Class Subcriptor
> Inherits ServicedComponent
> Implements EventClass.IEventosPedidos
>
> Public Sub PedidoRealizado(ByVal IdPedido As Integer) Implements
>EventClass.IEventosPedidos.PedidoRealizado
> Debug.WriteLine("Pedido nº" & IdPedido & " realizado")
> End Sub
>End Class
>
><Assembly: AssemblyVersion("1.0.0.0")>
><Assembly: AssemblyKeyFile("c:\eidos.snk")>
><Assembly: ApplicationName("Subscriptor")>
><Assembly: ApplicationActivation(ActivationOption.Library)>
><Assembly: ApplicationAccessControl(False)>
>
>And a Windows project, the client:
>
>Public Class Form1
> Inherits System.Windows.Forms.Form
>
> Dim s As Object = New Subscriptor.Subcriptor
> Dim st As New SubscripcionesTransitorias.SubscripcionesTransitorias
> Dim Id As String
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles Button1.Click
> p.RealizarPedido(1)
> End Sub
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles MyBase.Load
> Id = st.Añadir(s)
> End Sub
>End Class
>
>the exception is raised when calling st.Añadir(s).
>SubscripcionesTransitorias is implemented in a separate dll:
>
>Public Class SubscripcionesTransitorias
>
> Public Function Añadir(ByVal Objeto As Object) As String
> Dim cat As Object = CreateObject("COMAdmin.COMAdminCatalog")
>
> Dim Subscripciones As Object =
>cat.GetCollection("TransientSubscriptions")
> Dim Subscripción As Object = Subscripciones.Add()
> If Subscripción Is Nothing Then
> Throw New Exception("No se pueden añadir subscripciones
>transitorias")
> End If
>
> Subscripción.Value("Name") = "TransientSubscription"
> Subscripción.Value("EventCLSID") =
>"{DE1D42F4-3538-4D9D-B587-1B5F014D834F}"
>
>
> ' COMException "member not found." What member is not found ????
> Subscripción.Value("SubscriberInterface") = Objeto
>
> Subscripciones.SaveChanges()
> Añadir = Subscripción.Key
>
> Marshal.ReleaseComObject(Subscripción)
> Marshal.ReleaseComObject(Subscripciones)
> Marshal.ReleaseComObject(cat)
>
> End Function
>
> Public Sub Quitar(ByVal Id As String)
> Dim cat As Object = CreateObject("COMAdmin.COMAdminCatalog")
> Dim Subscripciones As Object =
>cat.GetCollection("TransientSubscriptions")
> Subscripciones.PopulateByKey(New String() {Id})
> If Subscripciones.Count = 1 Then
> Subscripciones.Remove(0)
> Subscripciones.SaveChanges()
> End If
> Marshal.ReleaseComObject(Subscripciones)
> Marshal.ReleaseComObject(cat)
>
> End Sub
>End Class
>
>I'm using Windows XP Service Pack 1a, Visual Studio 2003, and .NET Framework
>1.1
>
>Regards,
>
>Jesús López
>
>
>
>
>
>
Actually this would be even better for avoiding a refcount leak:
Dim pUnk As IntPtr = Marshal.GetIUnknownForObject(Objeto)
Subscription.Value("SubscriberInterface") = pUnk
Marshal.Release(pUnk)
Slava Gurevich
On Mon, 15 Dec 2003 08:06:33 -0500, Slava Gurevich <vyach@hotmail.com>
[quoted text, click to view] wrote:
>Hi,
>try the following:
>
> Subscription.Value("SubscriberInterface") =
>Marshal.GetIUnknownForObject(Objeto)
>
>
>Regards,
>
>Slava Gurevich
>
>
Thank you Slava,
The solution is a very simple test for transient subscriptions.
I Have a project "EventClass". This is the code:
Imports System.EnterpriseServices
Imports System.Runtime.InteropServices
<Guid("57CD98DE-81A5-4a0e-AED9-972428DA26EF")> _
Public Interface IEventosPedidos
Sub PedidoRealizado(ByVal IdPedido As Integer)
End Interface
<Guid("DE1D42F4-3538-4d9d-B587-1B5F014D834F"), _
EventClass(FireInParallel:=True), _
JustInTimeActivation(True), _
ObjectPooling(True)> _
Public Class EventosPedidos
Inherits ServicedComponent
Implements IEventosPedidos
Public Sub PedidoRealizado(ByVal IdPedido As Integer) Implements
IEventosPedidos.PedidoRealizado
Throw New NotImplementedException("Esta clase debe llamarse por
medio de eventos COM+")
End Sub
End Class
And here is the AssemblyInfo.vb:
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyKeyFile("c:\eidos.snk")>
<Assembly: ApplicationName("EventosPedidos")>
<Assembly: ApplicationActivation(ActivationOption.Server)>
<Assembly: ApplicationAccessControl(False)>
I have generated this project, put the assembly into the GAC and registered
it into COM+ using RegSvcs.exe
I also have a project "Subscriptor". And here is the code:
Imports System.EnterpriseServices
Public Class Subcriptor
Inherits ServicedComponent
Implements EventClass.IEventosPedidos
Public Sub PedidoRealizado(ByVal IdPedido As Integer) Implements
EventClass.IEventosPedidos.PedidoRealizado
Debug.WriteLine("Pedido nº" & IdPedido & " realizado")
End Sub
End Class
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyKeyFile("c:\eidos.snk")>
<Assembly: ApplicationName("Subscriptor")>
<Assembly: ApplicationActivation(ActivationOption.Library)>
<Assembly: ApplicationAccessControl(False)>
And a Windows project, the client:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim s As Object = New Subscriptor.Subcriptor
Dim st As New SubscripcionesTransitorias.SubscripcionesTransitorias
Dim Id As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
p.RealizarPedido(1)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Id = st.Añadir(s)
End Sub
End Class
the exception is raised when calling st.Añadir(s).
SubscripcionesTransitorias is implemented in a separate dll:
Public Class SubscripcionesTransitorias
Public Function Añadir(ByVal Objeto As Object) As String
Dim cat As Object = CreateObject("COMAdmin.COMAdminCatalog")
Dim Subscripciones As Object =
cat.GetCollection("TransientSubscriptions")
Dim Subscripción As Object = Subscripciones.Add()
If Subscripción Is Nothing Then
Throw New Exception("No se pueden añadir subscripciones
transitorias")
End If
Subscripción.Value("Name") = "TransientSubscription"
Subscripción.Value("EventCLSID") =
"{DE1D42F4-3538-4D9D-B587-1B5F014D834F}"
' COMException "member not found." What member is not found ????
Subscripción.Value("SubscriberInterface") = Objeto
Subscripciones.SaveChanges()
Añadir = Subscripción.Key
Marshal.ReleaseComObject(Subscripción)
Marshal.ReleaseComObject(Subscripciones)
Marshal.ReleaseComObject(cat)
End Function
Public Sub Quitar(ByVal Id As String)
Dim cat As Object = CreateObject("COMAdmin.COMAdminCatalog")
Dim Subscripciones As Object =
cat.GetCollection("TransientSubscriptions")
Subscripciones.PopulateByKey(New String() {Id})
If Subscripciones.Count = 1 Then
Subscripciones.Remove(0)
Subscripciones.SaveChanges()
End If
Marshal.ReleaseComObject(Subscripciones)
Marshal.ReleaseComObject(cat)
End Sub
End Class
I'm using Windows XP Service Pack 1a, Visual Studio 2003, and .NET Framework
1.1
Regards,
Jesús López
Thank you very very much Slava. That worked fine !!!
--=20
Regards,
Thank you again Slava.
--=20
Regards
Don't see what you're looking for? Try a search.