koszeggy / KGySoft.Drawing

KGy SOFT Drawing is a library for advanced image, icon and graphics handling.
https://kgysoft.net/drawing
Other
58 stars 8 forks source link

EntryPointNotFoundException: Unable to find an entry point named 'RtlCopyMemory' in DLL 'kernel32.dll'. #7

Closed wimpie3 closed 2 years ago

wimpie3 commented 2 years ago

As soon as I'm using the function SaveAsAnimatedGif, I get this exception in VB.NET with .NET 4.8:

EntryPointNotFoundException: Unable to find an entry point named 'RtlCopyMemory' in DLL 'kernel32.dll'.

koszeggy commented 2 years ago

Thank you for the report.

Ahh, this is a nasty one. There are some P/Invoke functions that use dirty inner hacks by the framework. These are just macros in WinAPI instead of real exported functions and unfortunately the mocked entry points are named differently in .NET Core and .NET Framework.

Firstly I used specific names on each platforms but that wasn't good either because sometimes the .NET Framework binaries needed to be executed on .NET Core (when using debugger visualizers, for example), so in the end I switched to the unified RtlCopyMemory name, which appeared to work everywhere... well, it seems I was just (un)lucky that it was working everywhere for me...

Could you please share some more environmental details, such as Windows version?

But in the end I will maybe switch to my ultimate fallback implementation even on Windows. This is now used by Mono/Linux, for example, if an older framework version is targeted where Buffer.MemoryCopy is not available.

Until then, you can try to target .NET Core 3.0 or later instead (eg. .NET 6) if you can switch to it in your project.

wimpie3 commented 2 years ago

Windows version 11. And unfortunately it's not possible to switch to .NET Core - that would require a complete rewrite of my software. I think a fallback implementation will be necessary if you don't want to lose .NET Framework developers.

koszeggy commented 2 years ago

Fixed by this commit. It will be in the next release soon.

if you don't want to lose .NET Framework developers

Don't be afraid of that. Compatibility with older frameworks has always been a priority, even .NET Framework 3.5 support is still maintained, even on Windows XP. All async methods have their pre-Task versions (Begin/End methods with IAsyncResult) and I don't plan to remove them. And I'm regularly fighting against Microsoft's breaking changes in order not to lose even Linux compatibility but it's not always that obvious.

wimpie3 commented 2 years ago

Thank you for fixing this bug so quickly! Any idea when the next version will be out (it's currently blocking the release of my software) ;-)

koszeggy commented 2 years ago

Any idea when the next version will be out

Hopefully still in this year. ;)

I want to add also an improvement to animgif generation when AllowDeltaFrames is true.

koszeggy commented 2 years ago

Fixed in v6.2.0

wimpie3 commented 2 years ago

Confirmed! It's working now! Thanks.