Open AlexanderPopovSLIC opened 10 months ago
Hello, not sure if it will help but I managed to make it work on windows aot by changing only one line
private static void LoadNetStandardDelegates(string userSpecifiedPath)
{
if (userSpecifiedPath != null)
{
if (WindowsNative.LoadLibraryEx(userSpecifiedPath, IntPtr.Zero, WindowsNative.LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH) == IntPtr.Zero)
{
// TODO: The Win32Exception class is not available in .NET Standard, which is the easy way to get the message string corresponding to
// a win32 error. FormatMessage is not straightforward to p/invoke, so leaving this as a job for another day.
throw new InvalidOperationException($"Failed to load librdkafka at location '{userSpecifiedPath}'. Win32 error: {Marshal.GetLastWin32Error()}");
}
}
- TrySetDelegates(new List<Type> { typeof(NativeMethods.NativeMethods) });
+ SetDelegates(typeof(NativeMethods.NativeMethods));
}
Having the same issue here (Publishing as trimmed, no AOT).
Description
If I publish my code in Native AOT then all parts of code which are related to Kafka usage (such as: Producers and Consumers) stopped working. I have got the next message in Console after running published to native AOT app
I'm using a very simple code which works in regular published app:
OS -> Windows 11
Nuget package is the latest one on the current moment Confluent.Kafka, Version=2.3.0.0, Culture=neutral, PublicKeyToken=12c514ca49093d1e
How to reproduce
dotnet publish -c Release -o "otput_path_where_app_will_be_published"
Checklist
Please provide the following information: