Autor |
Beitrag |
syox
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)
|
Verfasst: 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:
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 { public class cSharp { public cSharp() { }
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" };
public int S_N_A_F_U() { return 17; } } } |
Und ein Schnipsel aus Delphi
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; .... constructor WinForm_AssemblyTest.Create; begin inherited Create; InitializeComponent; fTest := cSharpDLL.cSharp.Create(); NameSpaceList := nil; self.i := 0; end; |
*cry*
|
|
Christian S.
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: 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
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)
|
Verfasst: Do 27.10.05 12:09
Habs jetzt so gemacht:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7:
| fTest := cSharpDLL.cSharp.Create(); NameSpaceList := nil; self.i := fTest.S_N_A_F_U(); |
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
Beiträge: 416
Delphi32 (D2005 PE); Chrome/C# (VS2003 E/A, VS2005)
|
Verfasst: 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
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)
|
Verfasst: Do 27.10.05 13:24
Die C#-Assembly steht bei den " uses":
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.
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: 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
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)
|
Verfasst: 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
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)
|
Verfasst: 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)
|
|
syox
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)
|
Verfasst: 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
Beiträge: 79
Windows XP
C#, VS2005 / VS2008
|
Verfasst: Do 27.10.05 17:31
Titel: Re: ?!!!
|
|
syox
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)
|
Verfasst: Mi 02.11.05 10:43
....
Da kann man ja nurnoch auf seinenFingernägeln kauen!
|
|
Christian S.
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: Mi 02.11.05 10:46
Titel: Re: ?!!!
Das Problem hatte ich irgendwie noch nie. Habe bei SharpPix oft irgendwelche Assemblies aktualisiert (C# und Delphi) und es wurden immer die korrekten verwendet
_________________ Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
|
|
syox
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)
|
Verfasst: 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...
|
|