🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.winforms.controls.using
Article #479

Re: Assembly Part 2 :)

#479
From: Stefanidis Dimitris
Date: Fri, 15 Oct 2004 07:49
129 lines
4143 bytes
Ok we have 3 different versions

Version 1 Simple String

Pckage2.dll :
TWinForm2.WinForm2:

Class procedure Foo_ex(var aVariable:String);
begin
  With Self.Create do
    begin
       ShowDialog;
       aVariable := 'THIS IS IT';
    end;
end;

Version 2 WinForm Object

Class procedure Foo_ex(var aVariable:TEditBox);
begin
  With Self.Create do
    begin
       ShowDialog;
       aVariable.Text := EditBox1.Text;
    end;
end;

Version 3 Vcl Objects :)


Class procedure Foo_ex(var aVariable:TSqlConnection);
begin
  With Self.Create do
    begin
       ShowDialog;
       aVariable.Open
    end;
end;


On caller exe

Version 1
 var
   ass   : Assembly;
   typ   : System.Type;
   cltyp : System.Type;
   meth  : MethodInfo;
   cl    :TObject;
   s     : string;
begin
  ass   := Assembly.LoadFrom('Package2.dll');
  typ   := ass.GetType('WinForm.TWinForm2');
  meth  := typ.GetMethod('Foo_Ex');
  cltyp := typ.GetNestedType('@Meta' + typ.Name);
  cl    := cltyp.GetField('@Instance').GetValue(nil);
  s := meth.Invoke(nil, [cl, s]) as string;
  TextBox1.Text := s;  <----- Empty String
end;


Version 2
 var
   ass   : Assembly;
   typ   : System.Type;
   cltyp : System.Type;
   meth  : MethodInfo;
   cl    :TObject;
 begin
  ass   := Assembly.LoadFrom('Package2.dll');
  typ   := ass.GetType('WinForm.TWinForm2');
  meth  := typ.GetMethod('Foo_Ex');
  cltyp := typ.GetNestedType('@Meta' + typ.Name);
  cl    := cltyp.GetField('@Instance').GetValue(nil);
  s := meth.Invoke(nil, [cl, TextBox1]) as string;  <----- Exception Null 
Refernce (aVarable in Foo_Ex is nil)
 end;

Version 3
 var
   ass   : Assembly;
   typ   : System.Type;
   cltyp : System.Type;
   meth  : MethodInfo;
   cl    :TObject;
 begin
 {
   MySqlConnection is TSqlConnection class with instance.
 }
  ass   := Assembly.LoadFrom('Package2.dll');
  typ   := ass.GetType('WinForm.TWinForm2');
  meth  := typ.GetMethod('Foo_Ex');
  cltyp := typ.GetNestedType('@Meta' + typ.Name);
  cl    := cltyp.GetField('@Instance').GetValue(nil);
  s := meth.Invoke(nil, [cl, MySqlConnection]) as string;  <----- System 
Argument Exception :" Object type cannot be converted to target type"  end;


I think we cover all possiblities :) (except in assembly there is vcl form 
insteed of FCL :) )
Let me explain what i;m trying to do :
I want my main application parted to dll's (assemlys);
I want my application does not know anything about the containing of dll's 
(not refernce) and load all dll's dynamicly when requested just by knowing 
in string Class name, Name and dll name.
I 'm gonna have an dll wich has all abstract objects and other dll's with 
child classes
In db all menu items and related dlls and classes with each menu item.
Ufff . That's all :) What are you thing ??? is it possible ?????

Thanks
Dimitris






"Marc Rohloff [TeamB]" <"on request"> wrote in message 
news:1xsxwwlxfiy0n.dlg@marcrohloff.40tude.net...
> On Thu, 14 Oct 2004 19:58:56 +0300, Stefanidis Dimitris wrote:
>
>> Any Ideas ??????
>
> You are going to have to show a bit more code.
>
> -- 
> Marc Rohloff [TeamB]
> marc rohloff at myrealbox dot com 
Technical Details
Message-ID: <416f80c2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <416eb016$1@newsgroups.borland.com> <1xsxwwlxfiy0n.dlg@marcrohloff.40tude.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1eff29,2ac59de14c919c27
X-Google-Attributes: gid1eff29,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stefanidis Dimitris" <distef01@yahoo.gr>
Newsgroups: borland.public.delphi.winforms.controls.using
References: <416eb016$1@newsgroups.borland.com> <1xsxwwlxfiy0n.dlg@marcrohloff.40tude.net>
Subject: Re: Assembly Part 2 :)
Date: Fri, 15 Oct 2004 10:49:18 +0300
Lines: 131
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 194.30.233.129
Message-ID: <416f80c2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097826498 194.30.233.129 (15 Oct 2004 00:48:18 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail