Recent

Author Topic: Importing TLB File, missing IDispatch Interface  (Read 842 times)

Weitentaaal

  • Hero Member
  • *****
  • Posts: 547
Importing TLB File, missing IDispatch Interface
« on: September 21, 2023, 08:39:49 am »
Hello,

i was importing a Wrapper Class DLL for a .NET assembly. i used the TLB which was generated when registering with regasm. Then Used the Import type library tool on the generated tlb File. Everything worked but when i tried to use the Type Library i got this Error: ACompaniesWrapper_1_0_tlb.pas(38,18) Error: default dispinterface ancestor IDispatch not found. why is no IDispatch interface created ? is there a Problem with the wrapper ? do i need to change/define an interface in the wrapper so that the tool can import the IDispatch too ? can i write the IDispatch myself ?

Here is the Generated Unit:

Code: Pascal  [Select][+][-]
  1. Unit ACompaniesWrapper_1_0_TLB;
  2.  
  3. {$mode delphi}{$H+}
  4.  
  5. interface
  6.  
  7. Uses
  8.   Windows,ActiveX,Classes,Variants;
  9. Const
  10.   ACompaniesWrapperMajorVersion = 1;
  11.   ACompaniesWrapperMinorVersion = 0;
  12.   ACompaniesWrapperLCID = 0;
  13.   LIBID_ACompaniesWrapper : TGUID = '{E1F9AE4A-596C-4FBE-A6D0-925BD6370C8E}';
  14.  
  15.   IID__ACompaniesWrapper : TGUID = '{8D53AB40-F6D8-4CF3-A129-F9938D80AB8A}';
  16.   CLASS_ACompaniesWrapper : TGUID = '{191B3B9F-F2B9-43D7-8AD8-7B471E3BB9A2}';
  17.  
  18. //Enums
  19.  
  20. //Forward declarations
  21.  
  22. Type
  23.  _ACompaniesWrapper = dispinterface;
  24.  
  25. //Map CoClass to its default interface
  26.  
  27.  ACompaniesWrapper = _ACompaniesWrapper;
  28.  
  29. //records, unions, aliases
  30.  
  31.  
  32. //interface declarations
  33.  
  34. // _ACompaniesWrapper :
  35.  
  36.  _ACompaniesWrapper = dispinterface
  37.    ['{8D53AB40-F6D8-4CF3-A129-F9938D80AB8A}']
  38.     // ExecuteCommand :  
  39.    function SomeFunction(var sRequestData:WideString):WideString;dispid 1;
  40.     // StartUp :  
  41.    function Init(sPathName:WideString):WideString;dispid 2;
  42.   end;
  43.  
  44. //CoClasses
  45.   CoACompaniesWrapper = Class
  46.   Public
  47.     Class Function Create: _ACompaniesWrapper;
  48.     Class Function CreateRemote(const MachineName: string): _ACompaniesWrapper;
  49.   end;
  50.  
  51. implementation
  52.  
  53. uses comobj;
  54.  
  55. Class Function CoACompaniesWrapper.Create: _ACompaniesWrapper;
  56. begin
  57.   Result := CreateComObject(CLASS_ACompaniesWrapper) as _ACompaniesWrapper;
  58. end;
  59.  
  60. Class Function CoACompaniesWrapper.CreateRemote(const MachineName: string): _ACompaniesWrapper;
  61. begin
  62.   Result := CreateRemoteComObject(MachineName,CLASS_ACompaniesWrapper) as _ACompaniesWrapper;
  63. end;
  64.  

the interface is declared like this:
Code: Pascal  [Select][+][-]
  1. <Guid("8D53AB40-F6D8-4CF3-A129-F9938D80AB8A"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
  2.  


Edit:

needed to change it to this:
Code: Pascal  [Select][+][-]
  1. <Guid("8D53AB40-F6D8-4CF3-A129-F9938D80AB8A"), InterfaceType(ComInterfaceType.InterfaceIsDual)> _
  2.  
« Last Edit: September 21, 2023, 11:24:12 am by Weitentaaal »

 

TinyPortal © 2005-2018