 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bert Hardeman Guest
|
Posted: Wed Apr 20, 2005 6:02 pm Post subject: Specified cast is not valid |
|
|
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 |
|
 |
|
|
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
|
|