Autor Beitrag
syox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 10:05 
Hallo zusammen,

habe hier eine Delphi.NET WinForms Applikation und ein selbstgebautes Assembly (allerdings in C# geschrieben). Die Kombination sollte kein Problem darstellen. Leider gibt es doch ein Problem.
In der WinForms Applikation kann ich zwar ein Objekt der (im Assembly.dll liegenden) Klasse erstellen aber auf keine einzige Methode zugreifen (nur den Konstruktor kann ich aufrufen lassen, sonst nur die von System.Object bekannt sind).

Hier der Quellcode vom cSharpDLL.cs:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
using System;
using System.Collections;

using System.Reflection;
using System.IO;

namespace cSharpDLL
{
  /// <summary>
  /// Zusammenfassende Beschreibung für Class1.
  /// </summary>
  public class cSharp
  {
    public cSharp()
    {
      //
      // TODO: Hier Konstruktorlogik einfügen
      //
    }

    public static string[] coreModuleNames = {
                                         "mscorlib.dll",
                                         "System.dll",
                                         "System.Windows.Forms.dll",
                                         "System.Drawing.dll",
                                         "System.Data.dll",
                                         "System.Xml.dll",
                                         "System.DirectoryServices.dll",
                                         "System.Web.dll"
                                       };

    // implementation
    public int S_N_A_F_U() {
      return 17;
    }
  } // Klasse schließen
// Namespace schließen


Und ein Schnipsel aus Delphi

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.Resources,
  System.Reflection, cSharpDLL;
...
  private
        fTest : cSharpDLL.cSharp;
....
// Konstruktor
constructor WinForm_AssemblyTest.Create;
begin
  inherited Create;
  //
  // Erforderlich für die Unterstützung des Windows Forms-Designers
  //
  InitializeComponent;
  //
  // Konstruktorcode
  //
  fTest := cSharpDLL.cSharp.Create();
  NameSpaceList :=  nil// fTest.S_N_A_F_U();  gibts nicht (mal davon abgesehen das es hier nen Typkonflikt geben würde)
  self.i := 0;
end;


*cry*
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 27.10.05 10:39 
Hallo!

Ich habe das gerade mal ausprobiert und bei mir kann ich das C#-Assembly problemlos nutzen. Delphi zeigt Dir in der Codevervollständigung aber natürlich nur die Methoden einer Klasse an, die auch an dieser Stelle passen. Könnte mir vorstellen, dass die Methode deswegen nicht angezeigt wird.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 12:09 
Habs jetzt so gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  fTest := cSharpDLL.cSharp.Create();
  NameSpaceList :=  nil// fTest.S_N_A_F_U();  gibts nicht (mal davon abgesehen das es hier nen Typkonflikt geben würde)
  self.i := fTest.S_N_A_F_U(); 
// ^^ da sagt mir die IDE:
(*Erzeugen
  [Fehler] AssemblyTester_Form.pas(420): E2003 Undefinierter Bezeichner: 'S_N_A_F_U'
  [Fataler Fehler] Assembly_Test.dpr(17): F2063 Verwendete Unit 'AssemblyTester_Form.pas' kann nicht compiliert werden *)


Zu meinem Projekt:
Es handelt sich um eine Projektgruppe, die die Hostanwendung (AssemblyTester_Form.pas) und ein C# Assembly (DLL) enthält.
Das C# Projekt befindet sich in einem Unterordner (relativ zum Delphi.NET Projekt).
Durch die Projektgruppe und die "uses"-Klausel im Delphi.NET-Code müsste doch das Assembly (cSharpDLL.dll) gefunden werden und funktionieren... müsste... aber es will nich (auf meinem Rechner) laufen...
Die cSharpDLL.dll existiert (hat auch nen aktuellen Timestamp, kann also nicht veraltet sein da ich ja das Projekt neu erzeuge).
Robert_G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416


Delphi32 (D2005 PE); Chrome/C# (VS2003 E/A, VS2005)
BeitragVerfasst: Do 27.10.05 13:15 
Du hast auch deine C#-Assembly referenziert?
.Net ist nicht mehr wie damals in Delphi32, wo man sich um irgendwelche Suchpfade für irgendwelche einzelnen Code dateien kümmern musste.
Du kompilierst gegen die Assemblies, die du referenzierst und in deine Assembly werden nur die Dateien deines Projektes kompostiert.[meta]Wobei sich D.Net hier wieder so wie früher verhält...[/meta]
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 13:24 
Die C#-Assembly steht bei den "uses":

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.Resources,
  System.Reflection,
  cSharpDLL;


Sollte da "uses cSharpDLL, ....;" nicht reichen?
Die cSharpDLL.dll liegt im selben Verzeichnis, in dem auch die "Assembly_Test.exe" liegt (in der Assembly_Test.exe steht "uses cSharpDLL, ...;" ).
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 27.10.05 13:46 
Hast Du in der Projektverwaltung die Referenz zu dem Assembly hinzugefügt?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 15:02 
Ist auch geschehen...
bin gerade dabei das ganze nochmal von gaaanz vorne zu beginnen.
Wenn es in 15 mins nicht geht dann is was mit meiner Delphi 2005 Prof. IDE faul... :/
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 16:00 
Titel: ?!!!
Joa, hab ein komplett neues Projekt erstellt und ein bischen probiert..
nun gehts!

Aber ich hab keinen Schimmer wieso es nicht ging (im alten Projekt).


Assembly war als Referenz eingebunden, stand in der Uses Klausel und funktioniert... (nur eben nicht im ursprünglichen Projekt) :?::idea::!: :shock:
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Do 27.10.05 16:22 
Titel: ?
habe gerade noch was erfahren:

die Funktion coreModuleNames existiert für das Assembly nicht:
cSharpDLL.cSharp.coreModuleNames gibt es nicht. Spielt diese Funktion eine Rolle?
Hab bei G o o g l e nichts darüber gefunden :(
Speedmaster
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 79

Windows XP
C#, VS2005 / VS2008
BeitragVerfasst: Do 27.10.05 17:31 
Titel: Re: ?!!!
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Mi 02.11.05 10:43 
:? :?
....
Da kann man ja nurnoch auf seinenFingernägeln kauen!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 02.11.05 10:46 
Titel: Re: ?!!!
user profile iconSpeedmaster hat folgendes geschrieben:
Guck mal hier:

www.delphipraxis.net...p;highlight=assembly
Das Problem hatte ich irgendwie noch nie. Habe bei SharpPix oft irgendwelche Assemblies aktualisiert (C# und Delphi) und es wurden immer die korrekten verwendet :gruebel:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
syox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22

WinXP, Debian GNU/Linux mit 2.6.13er Kernel
Visual Studio 6 (C/C++), , Borland Delphi 2005 Prof. (Delphi), Quanta+ (Perl, HTML, CSS)
BeitragVerfasst: Mi 02.11.05 15:07 
Titel: .::cry::.
Habe das Problem schonwieder...

Kanns sein das es daran liegt:
In der Projektgruppe ist die cSharpDLL nun mit eingebunden.
Die Projektgruppe besteht aus 2 Programmteilen. Die Hostapplikation auf der einen und die cSharpDLL Assembly auf der anderen.
Jetzt habe ich eine neue statische und eine "normale" Funktion geschrieben die aber (mal wieder) nicht aufrufbar sind, weil angeblich nicht existierend.
Habe die richtige cSharpDLL.dll eingebunden, habs bei der "uses"-Klausel stehen und kann nicht drauf zugreifen....
Werde noch Wahnsinnig...

Aber:
Das kann genausogut daran liegen das mein Delphi 2005 Architect Trail sich nicht patchen lassen möchte!
Am Donnesrtag krieg ich mein D2005Prof. geliefert... Vieleicht siehts dann besser aus...