xsharp.eu • C# und X509Certificate2 - Page 3
Page 3 of 3

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 7:31 am
by lagraf
Hallo,
ich versuche nun diese funktionierende C# App mit ILSpy + X#Plugin nach X# zu übertragen.
Dabei bekomme ich folgende C# Passage

Code: Select all

int choice;
if (int.TryParse(line, out choice) && (choice >= 0) && (choice <= readerNames.Length))
übersetzt mit

Code: Select all

LOCAL choice AS INT
IF ((int.TryParse(line, OUT choice )) .AND. (choice >= 0)) .AND. (choice <= readerNames:Length)
was folgenden Fehler beim Compilieren liefert

Code: Select all

error XS0103: The name 'int' does not exist in the current context	125,8	Program.prg	Program:ChooseReader
Entferne ich das int von int.TryParse erhalte ich den Fehler

Code: Select all

error XS0103: The name 'TryParse' does not exist in the current context	125,8	Program.prg	Program:ChooseReader
Was ist daran falsch?
LG

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 8:20 am
by wriedmann
Hallo Franz,
probier int32.TryParse()
Wolfgang

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 8:27 am
by lagraf
Hallo Wolfgang,
hat der Compiler erstmal akzeptiert.
Nachdem ich nun alle von C# nach X# falsch übernommenen Statements ausgebessert habe, werde ich die App nun durchtesten.
Danke, Franz

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 12:28 pm
by lagraf
ILSpy hat mir den Code der C# App wie folgt übersetzt:
Ich habe ein Hauptprogramm im File program.prg

Code: Select all

INTERNAL CLASS Program
PRIVATE STATIC METHOD Main() AS VOID
...
und eine Klasse im File AbstractCashRegisterSmartCard.prg

Code: Select all

INTERNAL ABSTRACT CLASS AbstractCashRegisterSmardCard IMPLEMENTS ICashRegisterSmartCard
...
Beim Compilieren kommt folgender Fehler bei AbstractCashRegisterSmartCard:

Code: Select all

error XS1558: 'Functions' does not have a suitable static 'Start' function	2,1	AbstractCashRegisterSmardCard.prg
Was sagt dieser Fehler aus?
LG

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 12:53 pm
by wriedmann
Hallo Franz,
in X# ist das anders zu verwenden:

Code: Select all

[STAThreadAttribute];
function Start( asCmdLine as string[] ) as int
	local nExitCode as int

	// Dein Appliktionscode - wahrscheinlich Aufruf Hauptfenster	

return nExitCode
Wolfgang

Re: C# und X509Certificate2

Posted: Wed Oct 22, 2025 4:02 pm
by lagraf
Hallo Wolfgang,
komisch, ich habe eine ähnliche X# App und da schaut program.prg genauso aus, trotzdem funktioniert diese App:

Code: Select all

INTERNAL CLASS Program
PRIVATE STATIC METHOD Start() AS VOID
An Start() oder Main() sollte es nicht liegen, habe ich schon probiert.
Unterschied ist nur, dass die funktionierende App nur 1 Klasse Program mit 1 Methode Start() in program.prg hat, die nicht funktionierende hat noch einige zusätzliche Methoden in program.prg und Files mit weiteren Klassen.
LG Franz

Re: C# und X509Certificate2

Posted: Thu Oct 23, 2025 10:06 am
by lagraf
Ich habe die X# App auf die FUNCTION Start() umgebaut und starte die Klasse Program daraus.
Damit läuft die X# App jetzt.