Invalid callback object instance
- From: aaron.m.johnson@xxxxxxxxx
- Date: 3 Jan 2007 11:35:57 -0800
I have a COM library written in C++. For asynchronous operations I use
a callback interface to notify the application of completions. Here's
the interface definition:
interface ICallback : IUnknown
{
HRESULT Execute(IUnknown* caller, DWORD data);
}
It's pretty standard from what I can tell. You pass in an object that
implements ICallback and the Execute method of that object is called
when the operation completes. The object that calls Execute passes a
pointer to itself (this) back via the first parameter, and a result
code via the second.
This all works great so long as the application is written in C++. I'm
having a problem with a sample app I wrote in C#, however. The object
I receive as the first parameter (caller) is not valid. The debugger
shows that it has the correct type, but if you try to access it you
wind up with invalid cast exceptions. Here's the shell of the Execute
method in my C# callback:
public void Execute(object caller, uint Data)
{
// caller has the right type, but it is not a valid object
}
Any ideas about what may be going on here? As far as I can tell, this
is the only place I'm having this kind of problem. Everything else in
the library works fine, and I'm creating, returning, and passing
various objects all over the place. It's just this one place.
I also wrote the same app in VB.NET, and got the exact same exceptions.
.
- Follow-Ups:
- Re: Invalid callback object instance
- From: Mattias Sjögren
- Re: Invalid callback object instance
- Prev by Date: Re: Why do I need regasm /codebase in this scenario?
- Next by Date: How Can I Use The Com+ Server From Client
- Previous by thread: Re: Why do I need regasm /codebase in this scenario?
- Next by thread: Re: Invalid callback object instance
- Index(es):
Relevant Pages
|