der henry: C# Programm läuft nur unter der IDE

Beitrag lesen

Hallo,

ich nutze unter Linux die IDE Rider. Hier läuft mein Programm ohne Probleme.

Um ein einzelnes "ausführbares" File zu bekommen, wird das Programm für Linux, siehe nachfolgend, "compiliert"

dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true -p:PublishTrimmed=true

Wenn ich nun auf dem gleichen Rechner in der auch die IDE läuft, das Programm starte kommt nachfolgende Fehlermeldung.

Unhandled exception. System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property. at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled() at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() at System.Text.Json.JsonSerializerOptions.MakeReadOnly(Boolean populateMissingResolver) at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions options, Type inputType) at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions options) at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options) at CommPLC.CommPLCProgram.readCpuCpInfo() at CommPLC.CommPLCProgram.openPLC_Device(String ip, Int32 rack, Int32 slot) at Program.Main(String[] args)

json nutze ich nur an einer Stelle "Funktion: readCpuCpInfo" ... ist klar.

Die lib habe ich über using System.Text.Json; eingebunden.

Wenn ich den Aufruf jsonString = JsonSerializer.Serialize(CpuInfoDic, options); herausnehme, funktioniert das Programm auch auf anderen Rechnern.

Ich verstehe nicht, warum diese lib nicht mit integriert wird, bzw. was im Detail die Fehlermeldung genau aussagt ? Alles andere mysql, System.Net.NetworkInformation, System.Security.Cryptography, System.Text usw. usw. nimmt er auch mit ins File und es läuft ??

Vielen Dank !!!