tags:

views:

110

answers:

1

I have created a lib which contains DateRange class in c#. I have created .dll and .tlb for that lib and registered the .tlb file. All the necessary steps has been done.

In Delphi, i used import type library option to produce a unit which contain the information of all classes which i created in c#.

Problem: I dont know how to use the member of DateRange class. Please help me.

Code I used in Delphi is...

program COMTesting;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  ComObj,
  MCenterComService_TLB in 'MCenterComService_TLB.pas';

var dr:DateRange;

begin
  dr:= createComObject(CLASS_DateRange) as DateRange;
  dr.fromdate:= date('4/16/2009');
  dr.todate:= date('4/16/2009');
end.

System says : [DCC Error] COMTesting.dpr(18): E2003 Undeclared identifier: 'fromdate'

+3  A: 

Undeclared identifier means the DateRange interface doesn't have a property called fromdate. Have a look at DateRange declaration in the generated MCenterComService_TLB.pas unit. There you will probably find methods Get_fromdate, Set_fromdate or similar. It's possible that the type library importer doesn't generate property declarations on interfaces. You can still use the getter/setter methods, though.

You could also add the property declarations manually yourself.

TOndrej
i am sure that fromdate,todate property has been declared datarange class in c#
Sarathi1904
As I said, the property declarations may have been lost during the type library import. Have a look in the generated unit.
TOndrej
oh my god, i think.. i can not resolve this. because i am not expert in delphi
Sarathi1904
OK, show the declaration of DateRange from your MCenterComService_TLB.pas unit. I'll try to show you a working solution.
TOndrej
+999 for TOndrej. Sarathi, sounds like an offer you can't (well.. shouldn't) refuse.
Wouter van Nifterick