Groups | Blog | Home
all groups > dotnet component services > november 2004 >

dotnet component services : Returning an IEnumerator from a ServicedComponent


Jo Siffert
11/10/2004 1:28:03 PM
Hi all,

I have a question regarding EnterpriseServices: I have a serviced
component (see below) that returns an IEnumerator. This Enumerator
should be returned by reference, of course. Howeverm when I try ti run
the code below, I get the exception:

System.Runtime.Remoting.RemotingException : 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.

Stack Trace:
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.Collections.IEnumerator.MoveNext()

Do I need to apply different attributes to the Enumerator class?

Thaks for your help,
Jo




The code:

< _
ClassInterface(ClassInterfaceType.None), _
Transaction(TransactionOption.Disabled), _
ComponentAccessControl(True), _
ConstructionEnabled(False), _
Description("Database Configuration"), _
EventTrackingEnabled(False), _
MustRunInClientContext(True), _
ObjectPooling(False), _
JustInTimeActivation(False), _
Synchronization(SynchronizationOption.Required) _
[quoted text, click to view]
Public Class FooManager
Inherits ServicedComponent
Implements IFooManager


' ...

Function List( _
ByVal parentId As Int32 _
) As IEnumerator Implements IFooManager.List
Return New FooEnumerator(parentId, m_dbCfg)
End Function

End Class

< _
ComVisible(True), _
ClassInterface(ClassInterfaceType.None) _
[quoted text, click to view]
Public Class FooEnumerator
Inherits MarshalByRefObject
Implements IEnumerator

'...

End Class
Robert Jordan
11/10/2004 1:51:57 PM
Hi Jo,

[quoted text, click to view]

Your enumerator must be derived from ServicedComponent.

bye
Tomas Restrepo \(MVP\)
11/10/2004 6:29:35 PM
Jo,

[quoted text, click to view]

Wouldn't make a difference; you're design doesn't lend to what you're trying
to do.

To actually get an enumerator to marshal by ref it would need to derive
somehow from MarshalByRefObject (usually done in your case by creating a
ServicedComponent-derived class).

So, in other words, this won't work anyway.

Seems to me, without knowing the full details of what you want to do, that a
much better option would be to return a *value* object (*not* a value type,
but a type that marshals by value and is [Serializable]) that implemented
IEnumerable, and contained an implementation of IEnumerator that was created
and executed in the *client* context by calling into a serviced component to
get the data on each call to IEnumerator::Next().

--
Tomas Restrepo
tomasr@mvps.org

AddThis Social Bookmark Button