Solved

Calling a Delphi COM object from ASP?

Posted on 2003-11-18
14
604 Views
Last Modified: 2013-11-23
I have the following ASP code to create my COM object:

    Dim objPal
    Dim aKey
    Response.Write("<p>")
    Set objPal = Server.CreateObject("VCTypeLib.VCAM")
    Response.Write("ok")
    aKey = objPal.LogOn("USER1", "PASSWORD")
    Response.Write(aKey)
    Response.Write("</p>")

This creates the COM object no problems, but I cannot then call any functions without getting the following error:

Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method

My thinking is that the VCTypeLib.VCAM relates to the Class GUID for my COM object, yet the interface with the functions on has a different GUID - so this could be why it cannot use the functions.

This is the first time I have tried to call a Delphi COM object from ASP, so any help would be most appreciated.
0
Comment
Question by:Greystoke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +3
14 Comments
 
LVL 3

Expert Comment

by:Peter_
ID: 9772138
Unless getting good answer, try posting to:
http://www.experts-exchange.com/Web/Web_Languages/ASP/ 
0
 
LVL 1

Expert Comment

by:TomBig
ID: 9772329
hi greystoke

some more information about your delphi class would sure be helpful.

what class does it inherit from, did you use the delphi typelib editor, what does the _TLB file look like etc.

isn't the logon method implemented on your class ?

cheers
TomBig
0
 
LVL 12

Accepted Solution

by:
andrewjb earned 100 total points
ID: 9772535
You'll need to derive from IDispatch instead of just IUnknown in your COM objects..
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Greystoke
ID: 9777102
Hi there,

Thanks for the tips; here is the type library....

//******************************************************************************************************//

// GUIDS declared in the TypeLibrary. Following prefixes are used:        
//   Type Libraries     : LIBID_xxxx                                      
//   CoClasses          : CLASS_xxxx                                      
//   DISPInterfaces     : DIID_xxxx                                      
//   Non-DISP interfaces: IID_xxxx                                        
// *********************************************************************//
  IID_IVCAM: TGUID = '{2684E893-409A-4C89-9AB3-927F4FAF7CD9}';
  IID_IVCAMInt: TGUID = '{7E3FC5F2-A2C7-41EE-88DD-EA631D40E875}';
  CLASS_VCAM: TGUID = '{153DF1C1-85D6-4F06-B5FB-D495AF1173AC}';


// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  IVCAM = interface;
  IVCAMDisp = dispinterface;
  IVCAMInt = interface;
  IVCAMIntDisp = dispinterface;



// *********************************************************************//
// Declaration of CoClasses defined in Type Library                      
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  VCAM = IVCAM;


// *********************************************************************//
// Interface: IVCAM
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {2684E893-409A-4C89-9AB3-927F4FAF7CD9}
// *********************************************************************//
  IVCAM = interface(IDispatch)
    ['{2684E893-409A-4C89-9AB3-927F4FAF7CD9}']
  end;

// *********************************************************************//
// DispIntf:  IVCAMDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {2684E893-409A-4C89-9AB3-927F4FAF7CD9}
// *********************************************************************//
  IVCAMDisp = dispinterface
    ['{2684E893-409A-4C89-9AB3-927F4FAF7CD9}']
  end;

// *********************************************************************//
// Interface: IVCAMInt
// Flags:     (320) Dual OleAutomation
// GUID:      {7E3FC5F2-A2C7-41EE-88DD-EA631D40E875}
// *********************************************************************//
  IVCAMInt = interface(IUnknown)
    ['{7E3FC5F2-A2C7-41EE-88DD-EA631D40E875}']
    function LogOn(const aUser: WideString; const aPass: WideString): WordBool; safecall;
  end;

// *********************************************************************//
// DispIntf:  IVCAMIntDisp
// Flags:     (320) Dual OleAutomation
// GUID:      {7E3FC5F2-A2C7-41EE-88DD-EA631D40E875}
// *********************************************************************//
  IVCAMIntDisp = dispinterface
    ['{7E3FC5F2-A2C7-41EE-88DD-EA631D40E875}']
    function LogOn(const aUser: WideString; const aPass: WideString): WordBool; dispid 201;
  end;

// *********************************************************************//
// The Class CoVCAM provides a Create and CreateRemote method to          
// create instances of the default interface IVCAM exposed by              
// the CoClass VCAM. The functions are intended to be used by            
// clients wishing to automate the CoClass objects exposed by the        
// server of this typelibrary.                                            
// *********************************************************************//
  CoVCAM = class
    class function Create: IVCAM;
    class function CreateRemote(const MachineName: string): IVCAM;
  end;

class function CoVCAM.Create: IVCAM;
begin
  Result := CreateComObject(CLASS_VCAM) as IVCAM;
end;

class function CoVCAM.CreateRemote(const MachineName: string): IVCAM;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_VCAM) as IVCAM;
end;

//******************************************************************************************************//

0
 

Author Comment

by:Greystoke
ID: 9777113
As you can see the COM class is derived from IDispatch but the interface from IUnknown and the methods are declared on the interface.

Is there any other info you require for a clearer picture?
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9777159
Hi,

You can't - to my knowledge - derive an interface from IUnknown and dispatch it.
It MUST derive from IDispatch.

HTH,

Andrew
0
 
LVL 1

Assisted Solution

by:TomBig
TomBig earned 75 total points
ID: 9777230
hi greystoke

i'm a little bit confused here. the comments of DeerBear and andrewjb are of course correct. the interface you want to use from vb must ne dispatchable. but you got two interfaces: IVCAM and IVCAMInt. IVCAM is derived from IDispatch and IVCAMInt from IUnknown. But your LogOn method is declared on IVCAMInt and not on IVCAM.

so in my opinion, if your class implements IVCAM it should be creatable from VB, but not if it implements IVCAMInt. but then on IVCAM there is not a single method declared. so indeed, from vb's point of view the object does not support the method.

and if i'm rightt then

 Set objPal = Server.CreateObject("VCTypeLib.VCAM")

creates a object that implements IVCAM (with no method declared). What is IVCAMInt anyway ?

cheers
0
 

Author Comment

by:Greystoke
ID: 9778935
Hmm, ok so in VBScript you can only connect to interfaces derived from IDispatch - can you then not cast them??  

I don't think so, as I read somewhere that VBScript cannot read IUnknown interfaces - but if someone could confirm this I'd be grateful.


I'm guessing then, that if I place my functions on the IDispatch interface then these can be accessed no problem?
0
 
LVL 5

Assisted Solution

by:DeerBear
DeerBear earned 75 total points
ID: 9778971
Hi,

VB can only see ONE specific IUnknown descendant, and that's IEnumVariant, for collection purpouses.

All the others can't be accessed, in VB you can't even "implements" them, because they're not listed.
HTH,

Andrew

P.S. I've been struggling with this for a month or so before understanding the
problem.
0
 
LVL 1

Expert Comment

by:wedgepilot
ID: 9778988
VBScript is late binding, so you must use Dispatch interfaces. Like others have said, implement the functions in IVCAM instead of IVCAMInt and all should be well.
0
 

Author Comment

by:Greystoke
ID: 9836791
Hi,

Thanks for all the info - I have made up a mock COM object with methods on the IDispatch interface and it all works fine.

Now for the points allocation...

Although andrewjb gave the right answer initially, TomBig and DeerBear have helped more by providing more verbose comments.

I propose

andrewjb - 100
TomBig - 75
DeerBear - 75

How does that sound?
0
 
LVL 1

Expert Comment

by:TomBig
ID: 9836910
Thats fine with me.
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9836947
Ditto.

Andrew
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 9837211
ok
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question