When running docker image ghcr.io/pxtools/pxwebapi:2.3.0 (on either linux or windows host) an error is reported on startup:
ERROR PCAxis.Paxiom.GroupRegistry - Error loading the valueset file: /app/wwwroot/Aggregations/REGION-EN.vs, Error message: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination (String parameters and return types must be paired with LPStr, LPWStr, or LPTStr).
This is due to PCAxis.Core/Grouping/GroupRegistry.vb is using an immutable String in its declaration of GetPrivateProfileStringW:
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L17
ChatGPT: "In the Windows API, GetPrivateProfileStringW expects a mutable buffer (a pointer to a writable character array). But in .NET:
- String is immutable
- Passing it ByVal means it cannot be written into safely
- On Windows, this sometimes “works by accident”
- On Linux (or stricter runtimes), it fails with your exact marshalling error"
The solution would be to replace String with a StringBuffer for lpReturnedString, BUT...
...solving this would probably still not work in a Linux based docker image or on a Linux based host due to lacking support of kernel32 in such images/hosts.
ChatGPT: "Even after fixing this, you still have a platform problem:
kernel32.dll is Windows-only
This API does not exist on Linux
So in a Linux container, this will eventually fail..."
A better solution would be to either reimplement Inireader.Read (in PCAxis.Core a.k.a. Paxiom) not to use GetPrivateProfileStringW or to reimplement PxFileDataSource (in PxWebApi) not to use PCAxis.Paxiom.Grouping.GroupRegistry.
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L45
|
Grouping grouping = PCAxis.Paxiom.GroupRegistry.GetRegistry().GetGrouping(id); |
My understanding is that PCAxis.Core (a.k.a. Paxiom) is not built when building the docker image but rather fetched from nuget repo.
When running docker image ghcr.io/pxtools/pxwebapi:2.3.0 (on either linux or windows host) an error is reported on startup:
ERROR PCAxis.Paxiom.GroupRegistry - Error loading the valueset file: /app/wwwroot/Aggregations/REGION-EN.vs, Error message: Cannot marshal 'parameter #1': Invalid managed/unmanaged type combination (String parameters and return types must be paired with LPStr, LPWStr, or LPTStr).This is due to PCAxis.Core/Grouping/GroupRegistry.vb is using an immutable String in its declaration of GetPrivateProfileStringW:
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L17
ChatGPT: "In the Windows API, GetPrivateProfileStringW expects a mutable buffer (a pointer to a writable character array). But in .NET:
The solution would be to replace String with a StringBuffer for lpReturnedString, BUT...
...solving this would probably still not work in a Linux based docker image or on a Linux based host due to lacking support of kernel32 in such images/hosts.
ChatGPT: "Even after fixing this, you still have a platform problem:
kernel32.dll is Windows-only
This API does not exist on Linux
So in a Linux container, this will eventually fail..."
A better solution would be to either reimplement Inireader.Read (in PCAxis.Core a.k.a. Paxiom) not to use GetPrivateProfileStringW or to reimplement PxFileDataSource (in PxWebApi) not to use PCAxis.Paxiom.Grouping.GroupRegistry.
https://github.com/PxTools/PCAxis.Core/blob/32810c504ffe6e908819c4ef6a21fe8abe7104fb/PCAxis.Core/Grouping/GroupRegistry.vb#L45
PxWebApi/PxWeb/Code/Api2/DataSource/PxFile/PxFileDataSource.cs
Line 135 in e5d9203
My understanding is that PCAxis.Core (a.k.a. Paxiom) is not built when building the docker image but rather fetched from nuget repo.