WebP-wrapper
WebP-wrapper copied to clipboard
System.NullReferenceException in UnsafeNativeMethods.OnCallback
UnsafeNativeMethods.OnCallback = new UnsafeNativeMethods.WebPMemoryWrite(MyWriter); is causing an exception:
System.NullReferenceException Object reference not set to an instance of an object. at UnsafeNativeMethods.WebPEncode_x64(WebPConfig& config, WebPPicture& picture) at WebP.AdvancedEncode(Bitmap bmp, WebPConfig config, Boolean info)
I can only seem to reproduce this on a server; running in development mode works fine.
I have updated the 64-bit library to version 1.2.1 Please try her. If you use the 32-bit version, I recommend you recompile this library. I have put instructions on how to do it in Compile dll.txt
Any updates on this? getting the same error :) and updated library didn't fix it for me
Please, test this change:
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)] You should end up with:
[DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false, ExactSpelling = true)] internal static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
Hey @JosePineiro , it was about a multi-threaded scenario for me, and the fact that OnCallback
was static. The WebP
class was being accessed/instantiated by multiple threads therefore OnCallback
was being set null, and I was getting those NullReferenceExceptions. I made OnCallback
an instance property and made sure to release it properly, it solved it for me. Thanks!