Board index » delphi » IDispatch - Invalid class typecast error ??

IDispatch - Invalid class typecast error ??

Hello to all,

I'm having some troubles with an Automation object. It's typed as

    TInitialiser = class(TAutoObject, IInitialiser)

and implements the IInitialiser interface. I want to create an instance of
this object within an ASP page with the command

  Set init=CreateObject("MyDLL.Initializer")

which requires the object to implements to implement IDispatch. Initially I
didn't know about this and therefore I create the object
as a descendant of TTypedComObject. Now I want to change it to TAutoObject
to have it implement IDispatch, but when I changed
the declaration of my class, I got the error "Invalid class typecast".

I also reviewed the flags on the interface, they only specify the "Ole
automation" flag. Do I have to check more flags ?
Perhaps the Dual flag (from the documentation I figured this might help, but
when I check it, I get the message
"Parent interface must be dispatchable for dual interface").

Any help will be appreciated!

Regards,
Jeroen Bijleveld

 

Re:IDispatch - Invalid class typecast error ??


I just solved this problem! My interface IInitialiser inherited from
IUnknown, I had to change this to IDispatch.
Hope this will help some else with the same sort of problem

Regards, Jeroen Bijleveld

"Anonymous" <Newsgro...@Abyss.nl> schreef in bericht
news:3ae043d2$1_2@dnews...

Quote
> Hello to all,

> I'm having some troubles with an Automation object. It's typed as

>     TInitialiser = class(TAutoObject, IInitialiser)

> and implements the IInitialiser interface. I want to create an instance of
> this object within an ASP page with the command

>   Set init=CreateObject("MyDLL.Initializer")

> which requires the object to implements to implement IDispatch. Initially
I
> didn't know about this and therefore I create the object
> as a descendant of TTypedComObject. Now I want to change it to TAutoObject
> to have it implement IDispatch, but when I changed
> the declaration of my class, I got the error "Invalid class typecast".

> I also reviewed the flags on the interface, they only specify the "Ole
> automation" flag. Do I have to check more flags ?
> Perhaps the Dual flag (from the documentation I figured this might help,
but
> when I check it, I get the message
> "Parent interface must be dispatchable for dual interface").

> Any help will be appreciated!

> Regards,
> Jeroen Bijleveld

Re:IDispatch - Invalid class typecast error ??


<<Anonymous:
when I changed the declaration of my class, I got the error
"Invalid class typecast".

Quote

What did you do? Did you make the interface descend from
IDispatch using the Type Library Editor? Did you make the
implementing object descend from TAutoObject? Did you
change the initialization section to refer to
TAutoObjectFactory?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads