List Info

Thread: Passing an object reference back from a COM+ hosted object




Passing an object reference back from a COM+ hosted object
user name
2007-01-05 22:11:25
Mike,

The property that I am accessing is actually just a public
function.
Here is the code for my test class :

Imports System.EnterpriseServices
Imports CTRL
Imports System.Threading

<Assembly:
ApplicationActivation(ActivationOption.Server)> 
<Assembly: ApplicationName("SimpleTrans")> 
<Assembly: Description("Simple Transactional
application to show
Enterprise Services")> 
<Assembly: ApplicationAccessControl(False)> 
' <Transaction(TransactionOption.RequiresNew)> _
Public Class VBServCom
    Inherits EnterpriseServices.ServicedComponent

    Private oLib As CTRL.Library

    ' Shows Explicit SetComplete/SetAbort.
    Public Function DoTrans() As String
        Dim name As String
        name = "this is a test"
        DoTrans = name
    End Function


    Public Function GetLibrary() As Object

        oLib = New CTRL.Library ' make a new Library object

        GetLibrary = oLib  ' finally, return the Library
object ...

    End Function 

    ' Show implicit SetComplete/SetAbort.
    <AutoComplete(True)> _
    Public Sub DoTxAuto()
        'Do stuff
    End Sub

End Class


My clients code is the following :

Imports ServicedCOM.VBServCom

Module Module1
    Sub Main()
        Dim o As ServicedCOM.VBServCom
        Dim s As String
        Dim oLibrary As CTRL.Library

        o = New ServicedCOM.VBServCom
        s = o.DoTrans
        Console.WriteLine("Result was : " & s)

        oLibrary = o.GetLibrary()

        Console.WriteLine("Result was : " &
oLibrary.Version)

    End Sub
End Module

So I am getting the error when I try and execute the
oLibrary.Version
method.  The o.GetLibrary() call executes but I'm not sure
its returning
anything useful.  Also, the CTRL.Library object inherits
from
MarshalByRef so I know it can be remoted.   I didn't think
that I had to
setup channels or sinks when using Component
Services/EnterpriseServices.  I know how to do this when
doing remoting
but I'm not sure how it would work in the Component
Services/EnterpriseServices configuration.

Thanks,
Nick




-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:ADVANCED-DOTNETDISCUSS.DEVELOP.COM] On Behalf Of Mike
Woodring
Sent: Thursday, January 04, 2007 7:42 PM
To: ADVANCED-DOTNETDISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Passing an object reference
back from a
COM+ hosted object

> The call to the new method worked,
> but when I try and reference a property of the object
that I just got 
> passed back, I get the following error :

What's the type of the property you're accessing, and are
you accessing
it's setter or getter?

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsigh
t.com/mike

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Passing an object reference back from a COM+ hosted object
user name
2007-01-06 00:17:27
> So I am getting the error when I try and execute the
oLibrary.Version
> method.  The o.GetLibrary() call executes but I'm not
sure
> its returning
> anything useful.

In the debuggger, if you hover your cursor over the oLibrary
variable after
you execute this line:

        oLibrary = o.GetLibrary()

(or put a watch on it), does the debugger confirm that
oLibrary is a
TransparentProxy?

> Also, the CTRL.Library object inherits from
> MarshalByRef so I know it can be remoted.   I didn't
think
> that I had to
> setup channels or sinks when using Component
> Services/EnterpriseServices.  I know how to do this
when
> doing remoting
> but I'm not sure how it would work in the Component
> Services/EnterpriseServices configuration.

You answered the first question I had, was wondering which
direction the
error applied to.  For example, if you were setting a
property, instead of
getting it; and you were passing a reference to an object on
the client
side, and in the setter (over on the server), the setter
tried to invoke a
method/etc - this would be a callback attempt from
server-to-client.  Ditto
an attempt to register for an event.  So I was wondering if
it was the lack
of a server channel on the client that was the glitch.  But
if you're just
calling a getter, then that rules that out.

You mentioned that CTRL.Library extends MBRO, but is that
class marked
public?

Nothing's jumped out at me, but I don't use COM+ much/at all
in recent
years.  But you ruled out the one common issue I was
thinking of...

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsigh
t.com/mike

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )