HighTechTalks DotNet Forums  

ServicedComponent: COM object separated from its underlying RCW?

Dotnet Framework (Component Services) microsoft.public.dotnet.framework.component_services


Discuss ServicedComponent: COM object separated from its underlying RCW? in the Dotnet Framework (Component Services) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jo Siffert
 
Posts: n/a

Default ServicedComponent: COM object separated from its underlying RCW? - 11-10-2004 , 11:24 AM






Hi,

I have defined the following ServicedComponent that currently does nothing.

< _
ClassInterface(ClassInterfaceType.None), _
Guid("D374C669-3779-45da-83F4-5D2279F0355B") _
Quote:
_
Public Class BarEnumerator
Inherits ServicedComponent
Implements IEnumerator

Private ReadOnly Property Current() As Object Implements
IEnumerator.Current
End Property

Private Function MoveNext() As Boolean Implements IEnumerator.MoveNext
End Function

Private Sub Reset() Implements IEnumerator.Reset
End Sub

Public Overloads Sub Dispose()
End Sub
End Class

It is deployed as a server application. I can instantiate this class and
invoke Current. When I call MoveNext(), the following exception is thrown:

System.Runtime.InteropServices.InvalidComObjectExc eption : COM object
that has been separated from its underlying RCW can not be used.

Stack Trace:
at System.Runtime.Remoting.Messaging.StackBuilderSink
.PrivateProcessMessage(
MethodBase mb, Object[] args, Object server,
Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink
.SyncProcessMessage(
IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(
IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy
.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Collections.IEnumerator.MoveNext()

For me this sounds like an Apartment-related problem, but I do not know
how to fix it using ES...

Thanks,
Jo


Reply With Quote
  #2  
Old   
Robert Jordan
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-10-2004 , 11:38 AM






Hi,

Quote:
I have defined the following ServicedComponent that currently does nothing.
I'm clueless about VB.NET, so I don't understand why
the methods/properties can be empty.

The following C#-Enumerator works as expected:

public class TestEnumerator : ServicedComponent, IEnumerator {
readonly string[] strings = new string[] {"hello", "world"};
IEnumerator innerEnum;

public TestEnumerator() {
innerEnum = strings.GetEnumerator();
}

public object Current {
get {
return innerEnum.Current;
}
}

public void Reset() {
innerEnum.Reset();
}

public bool MoveNext() {
return innerEnum.MoveNext();
}
}

bye
Rob


Reply With Quote
  #3  
Old   
Jo Siffert
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-10-2004 , 01:33 PM



Hi Robert,

even with your dummy implementation I get the same exception. However,
when I do not implement IEnumerator and use the class interface instead,
everything works fine.
Are there any restrictions with the IEnnumerator/IEnumVARIANT-RCW?

Thanks,
Jo

Robert Jordan wrote:

Quote:
Hi,

I have defined the following ServicedComponent that currently does
nothing.


I'm clueless about VB.NET, so I don't understand why
the methods/properties can be empty.

The following C#-Enumerator works as expected:

public class TestEnumerator : ServicedComponent, IEnumerator {
readonly string[] strings = new string[] {"hello", "world"};
IEnumerator innerEnum;

public TestEnumerator() {
innerEnum = strings.GetEnumerator();
}

public object Current {
get {
return innerEnum.Current;
}
}

public void Reset() {
innerEnum.Reset();
}

public bool MoveNext() {
return innerEnum.MoveNext();
}
}

bye
Rob

Reply With Quote
  #4  
Old   
Robert Jordan
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-10-2004 , 01:47 PM



Jo Siffert wrote:

Quote:
Hi Robert,

even with your dummy implementation I get the same exception. However,
when I do not implement IEnumerator and use the class interface instead,
everything works fine.
Are there any restrictions with the IEnnumerator/IEnumVARIANT-RCW?
No, they aren't. Do you implement IEnumerable somewhere?
In you previous post I saw that you don't:

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

You are suppose to:

Public Class FooManager
Inherits ServicedComponent
Implements IFooManager, IEnumerable <---

Function GetEnumerator ....
Return New FooEnumerator(parentId, m_dbCfg)

bye
Rob


Reply With Quote
  #5  
Old   
Jo Siffert
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-11-2004 , 03:03 AM



Robert Jordan wrote:
Quote:
Jo Siffert wrote:

Hi Robert,

even with your dummy implementation I get the same exception. However,
when I do not implement IEnumerator and use the class interface
instead, everything works fine.
Are there any restrictions with the IEnnumerator/IEnumVARIANT-RCW?


No, they aren't. Do you implement IEnumerable somewhere?
In you previous post I saw that you don't:
No, I did not. Do I have to even if my class does not have collection
semantics?

Thanks,
Jo

Quote:
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

You are suppose to:

Public Class FooManager
Inherits ServicedComponent
Implements IFooManager, IEnumerable <---

Function GetEnumerator ....
Return New FooEnumerator(parentId, m_dbCfg)

bye
Rob

Reply With Quote
  #6  
Old   
Jo Siffert
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-11-2004 , 10:07 AM



Hi,

it seems to have been a bug in the Framework - after installing SP1
everything works fine...

Thanks though,
Jo

Jo Siffert wrote:

Quote:
Robert Jordan wrote:

Jo Siffert wrote:

Hi Robert,

even with your dummy implementation I get the same exception.
However, when I do not implement IEnumerator and use the class
interface instead, everything works fine.
Are there any restrictions with the IEnnumerator/IEnumVARIANT-RCW?



No, they aren't. Do you implement IEnumerable somewhere?
In you previous post I saw that you don't:

No, I did not. Do I have to even if my class does not have collection
semantics?

Thanks,
Jo


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

You are suppose to:

Public Class FooManager
Inherits ServicedComponent
Implements IFooManager, IEnumerable <---

Function GetEnumerator ....
Return New FooEnumerator(parentId, m_dbCfg)

bye
Rob

Reply With Quote
  #7  
Old   
Robert Jordan
 
Posts: n/a

Default Re: ServicedComponent: COM object separated from its underlying RCW? - 11-11-2004 , 10:37 AM



Hi Jo,

Quote:
it seems to have been a bug in the Framework - after installing SP1
everything works fine...
Glad to hear it works! I tested the enumerator with SP1. No chance
to discover that myself, because my "production" components running
on a machine w/out SP1 don't implement an enumerator.

bye
Rob


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.