BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Specified cast is not valid

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Bert Hardeman
Guest





PostPosted: Wed Apr 20, 2005 6:02 pm    Post subject: Specified cast is not valid Reply with quote



Hi,

I have a problem when accessing a service using automation.

In D6 I have this working using the following line:

Root := CreateOleObject ('BvDbs.PtBvRoot') as IPTBVRoot;

Now I want to access the same COM object from a Delphi2005 .NET web
application. I use the following code to access the object:

RootType := System.Type.GetTypeFromProgID('BvDbs.PtBvRoot');
Root := Activator.CreateInstance(RootType) as IPTBVRoot;

Tasks := (Root as IPTBVRoot).GetTasks as IPtBvTaskTable;

When I run the application and use Casini to host the web application I can
retrieve data and everything works as expected. However when I use IIS to
host the application then the typecast 'Root as IPTBVRoot' throws an
exception:

System.InvalidCastException: Specified cast is not valid.

When I put a breakpoint after the CreateInstance line and evaluate the
content of ROOT then IIS returns a different value than Casini.
Casini value: Root = {83709856, null reference, null reference}
IIS valu e : Root = {54080952, null reference, null reference}

It seems that when using IIS a pointer to a different object is return
causing the typecast to fail.

Does anyone has any idea what could be wrong?

Thanks in advance.

Bert




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.