Dexter said:
pompomJuice said:
*snip*
I should have been more explicit about proxy/marshaling. Marshaling is something you don't need to be concerned about in .NET  because the runtime will do that automatically. What the Dr. Dobb's article says only applies to the unmanaged world.

Of course, that brings the question why this doesn't work if it's done automatically. That's because this marshaling requires that the component (or more exactly the interface) has a registered proxy. So your component is either not registered correctly or it doesn't have a proxy at all.

As for the RCW error: I've never seen that before. Could you post a stack trace or at least the exact line that causes that?

PS: you still need to figure out if your COM object is apartment threaded or free threaded Smiley

Thanks for that information.

I have mailed the original authors of those COM objects for those questions.

Also thanks for pointing out my miss interpretation of Dr. Dobbs. I also wondered about that, since he never mentions .Net in the article itself, only the heading. I think the heading might be wrong.

All other research I did also pointed out that everything should just work. Oh well, kind of fixed that problem by removing them out of the invokes.

Now the other error: I have checked it out for about 5 minutes. It looks less involved. There error seems to happen all on its own in one method call. Here it is:

 
public void SetClientRect(Rectangle rcClient) // exception
{
   if (m_objClientEnvelope == null)
      m_objClientEnvelope = new SMEnvelopeClass(); // The COM object
  m_objClientEnvelope.XMin = rcClient.Left;// <---- EXCEPTION happens here on m_objClientEnvelope
  m_objClientEnvelope.XMax = rcClient.Right;
  m_objClientEnvelope.YMin = rcClient.Top;
  m_objClientEnvelope.YMax = rcClient.Bottom;
  ((IDisplayTransformation)m_objTransformation).ClientRect = m_objClientEnvelope; // exception
}

//The interface generated by that Assembly generator
[Guid( "C3D7F3E5-28D7-407F-BBED-CF8F2222BE35" )]
[TypeLibType( 2 )]
[ClassInterface( 0 )]
public class SMEnvelopeClass : SMEnvelope, IEnvelope
{
   public SMEnvelopeClass();
  [DispId( 4 )]
  public virtual double XMax { get; set; }
  [DispId( 3 )]
  public virtual double XMin { get; set; }
  [DispId( 2 )]
  public virtual double YMax { get; set; }
  [DispId( 1 )]
  public virtual double YMin { get; set; }
}


Ok so again I think its a threading problem because that method instantiates m_objClientEnvelope the first time it is called. I injected a thread id call there and it is clear that if the creating thread accesses that member it works, if the thread ID changes it fails with that error. I think its a different kind of error for the same problem, those threads are not part of the same apartment and the marshalling between the apartments ( or thread and apartment? ) is not working? I am guessing here, my COM knowledge is a day old. Baby steps.

I think with the previous error I got lucky. A worker thread instantiated the COM object and used it inside that worker thread. Because I eliminated the other thread created by invoke I sidestepped that problem.

The new error occurs because two worker threads ( that are essential to the program ) are trying to access the same COM object. This time trickery might not work. Sigh.... I am out of ideas here.

With regards to your comment "So your component is either not registered correctly or it doesn't have a proxy at all." Basically what I did was regsvr32 smmobile.dll and tlbimp smmobile.dll /out:NETSMMobile.dll and referenced that NETSMMobile.dll in my devStudio. I read about that proxy/stub file and I have no idea if that information was "imbedded" within the COM object itself. But I don’t have that proxy dll file that they speak of.

Thanks for the help.

Regards,