You know, another option might be using the MeowMoniker [1].  I believe that
the display name of this moniker will be the same across apartments.

[1]  http://www.sellsbrothers.com/tools/monikers/

> -----Original Message-----
> From: Dmitry Shaporenkov [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 12, 2003 9:42 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] Object identities, marshaling
> issues and interoperability
>
>
> ----- Original Message -----
> From: "Jim Sievert" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, September 12, 2003 6:17 PM
> Subject: Re: [ADVANCED-DOTNET] Object identities, marshaling
> issues and
> interoperability
>
>
> > Besides your solution, perhaps the GIT may help.  I'm not
> 100% sure about
> > this, though.  Assuming you're wrapping your COM object,
> the creation of
> > such a wrapper could register the object in the GIT.  The
> question is
> > whether or not you can register the same object multiple
> times (from two
> > different apartments no less).  If you can, the same cookie
> should be
> > returned.  I believe you can use this cookie as your Hashtable key?
>
>     Surely. Thanks for fresh idea about GIT, Jim, I'll try it.
>
> >
> > > -----Original Message-----
> > > From: Dmitry Shaporenkov [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, September 12, 2003 7:55 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [ADVANCED-DOTNET] Object identities, marshaling
> > > issues and interoperability
> > >
> > >
> > > ----- Original Message -----
> > > From: "Jim Sievert" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Friday, September 12, 2003 4:20 PM
> > > Subject: Re: [ADVANCED-DOTNET] Object identities, marshaling
> > > issues and interoperability
> > >
> > >
> > > > Your best bet is to compare objects based on their
> > > IUnknowns.  You can
> > > > use
> > > > GetIUnknownForObject() for this (don't forget to call
> > > Release when you're
> > > > done).
> > >
> > >    This is exactly what I'm trying to do.
> > >
> > > > Because these IUnknown values are Apartment relative, you
> > > just can't
> > > > plop the IUnknown as a key in the Hashtable.  You're going
> > > to have to
> > > > do some work -- probably by specializing the Hashtable...
> > >
> > >    Yes, but I can't figure out how this work could be done.
> > > May be I need to marshal IUnknown to a stream and
> > >    then use contents of the stream as an identity? If the
> > > contents of the stream is apartment-independent, this
> will probably
> > >    work, but such a solution is obviously inefficient. Or do
> > > I need something else?
> > >
> > >    COM experts, please advise!
> > >
> > > > -----Original Message-----
> > > > From: Dmitry Shaporenkov [mailto:[EMAIL PROTECTED]
> > > > Sent: Friday, September 12, 2003 4:25 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [ADVANCED-DOTNET] Object identities,
> marshaling issues and
> > > > interoperability
> > > >
> > > >
> > > > Hi all,
> > > >
> > > > I need help in a problem concerning COM/.NET
> interoperability in a
> > > > multithreaded application. The application (written in
> > > > C#) uses an external component which exposes COM-based
> > > object model.
> > > > Let's say 'Item' is an object of the model, item has a
> __CComObject
> > > > type. Items are accessed via calls to the component like
> > > the follows:
> > > >
> > > > ....
> > > >    Item anItem =  externalObject.GetItem ("MyItem");
> > > > ....
> > > >
> > > > During startup a worker thread is running to collect some
> > > information
> > > > about items and store it in a hashtable (using items as
> the keys):
> > > >
> > > > ....
> > > >     Hashtable theCache = new Hashtable ();
> > > >     theCache [anItem] = <something>;
> > > > ...
> > > >
> > > > The information is then used from code executing in the
> UI thread:
> > > >
> > > > ...
> > > >    Item anItem =  externalObject.GetItem ("MyItem");
> > > >    <something> = theCache [anItem]; // Oops. This does
> not work ...
> > > >
> > > > The problem is that, because UI thread lives in a STA and
> > > the worker
> > > > thread executes in another apartment, the UI thread
> gets different
> > > > wrapper than the worker thread, since items are
> marshalled across
> > > > apartments. I realize that this is normal behavior.
> > > However, I need a
> > > > way to identify items in a thread-independent fashion. Items
> > > > themselves do not have any properties which might serve as
> > > a reliable
> > > > unique identifiers.
> > > >
> > > > So, the question is, how such problems are resolved? May be
> > > there is
> > > > still a way to get apartment-independent identifier of the
> > > object? I
> > > > am not a COM guru, but I took a look at
> > > > System.Runtime.InteropServices.Marshal class and found nothing
> > > > similar.
> > > >
> > > > Any advices / references will be greatly appreciated. Thanks in
> > > > advance.
> > > >
> > > > Regards,
> > > > Dmitry Shaporenkov
> > > > mailto:[EMAIL PROTECTED]
> > > >
> > > > ===================================
> > > > This list is hosted by DevelopMentor-
> http://www.develop.com NEW!
> > > > ASP.NET courses you may be interested in:
> > > >
> > > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> > > > http://www.develop.com/courses/2daspdotnet
> > > >
> > > > Guerrilla
> > > > ASP.NET, 13 Oct 2003, in Boston
> > > > http://www.develop.com/courses/gaspdotnet
> > > >
> > > > View archives and
> > > > manage your subscription(s) at http://discuss.develop.com
> > > >
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor-  http://www.develop.com
> > > NEW! ASP.NET courses you may be interested in:
> > >
> > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> > > http://www.develop.com/courses/2daspdotnet
> > >
> > > Guerrilla
> > > ASP.NET, 13 Oct 2003, in Boston
> > > http://www.develop.com/courses/gaspdotnet
> > >
> > > View archives and
> > > manage your subscription(s) at http://discuss.develop.com
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor-  http://www.develop.com
> > > NEW! ASP.NET courses you may be interested in:
> > >
> > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> > > http://www.develop.com/courses/2daspdotnet
> > >
> > > Guerrilla
> > > ASP.NET, 13 Oct 2003, in Boston
> > > http://www.develop.com/courses/gaspdotnet
> > >
> > > View archives and
> > > manage your subscription(s) at http://discuss.develop.com
> > >
> >
> > ===================================
> > This list is hosted by DevelopMentor╝  http://www.develop.com
> > NEW! ASP.NET courses you may be interested in:
> >
> > 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> > http://www.develop.com/courses/2daspdotnet
> >
> > Guerrilla ASP.NET, 13 Oct 2003, in Boston
> > http://www.develop.com/courses/gaspdotnet
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor╝  http://www.develop.com
> NEW! ASP.NET courses you may be interested in:
>
> 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> http://www.develop.com/courses/2daspdotnet
>
> Guerrilla ASP.NET, 13 Oct 2003, in Boston
> http://www.develop.com/courses/gaspdotnet
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor╝  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

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

Reply via email to