Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / December 2003

Tip: Looking for answers? Try searching our database.

COMException when registering a LCE transient subscription

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SqlRanger - 09 Dec 2003 13:59 GMT
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 ?

Signature

Regards,

Jesús López

SqlRanger - 13 Dec 2003 14:28 GMT
Any help, please.

I'm posting with my MSDN alias. So, why Microsoft guys don't anwer me ?

Signature

Regards

Jesús López

Slava Gurevich - 13 Dec 2003 20:14 GMT
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

>I'm using this code to register a LCE transient subscription:
>
[quoted text clipped - 19 lines]
>
>Please , could you help me ?
SqlRanger - 15 Dec 2003 09:25 GMT
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
Slava Gurevich - 15 Dec 2003 13:06 GMT
Hi,
try the following:

Subscription.Value("SubscriberInterface") =
Marshal.GetIUnknownForObject(Objeto)

Regards,

Slava Gurevich

>Thank you Slava,
>
[quoted text clipped - 129 lines]
>
>Jesús López
Slava Gurevich - 15 Dec 2003 14:57 GMT
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

>Hi,
>try the following:
[quoted text clipped - 5 lines]
>
>Slava Gurevich
SqlRanger - 15 Dec 2003 15:27 GMT
Thank you again Slava.

Signature

Regards

Jesús López

SqlRanger - 15 Dec 2003 15:00 GMT
Thank you very very much Slava. That worked fine !!!

Signature

Regards,

Jesús López


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.