Closed DiracSpace closed 2 years ago
The previous question works but I'm getting this issue and can't seem to pinpoint the problem.
Message: "Unable to find an entry point named 'CopyMemory' in DLL 'kernel32.dll'.\r\nIn WebP.AdvancedEncode"
It seems to arrive to this part of the code in the wrapper:
// not working
//compress the input samples
if (UnsafeNativeMethods.WebPEncode(ref config, ref wpic) != 1)
throw new Exception("Encoding error: " + ((WebPEncodingError)wpic.error_code).ToString());
That jumps to this code here and it breaks upon entering WebPEncode_x64
/// <summary>Compress to WebP format</summary>
/// <param name="config">The configuration structure for compression parameters</param>
/// <param name="picture">'picture' hold the source samples in both YUV(A) or ARGB input</param>
/// <returns>Returns 0 in case of error, 1 otherwise. In case of error, picture->error_code is updated accordingly.</returns>
internal static int WebPEncode(ref WebPConfig config, ref WebPPicture picture)
{
switch (IntPtr.Size)
{
case 4:
return WebPEncode_x86(ref config, ref picture);
case 8:
return WebPEncode_x64(ref config, ref picture);
default:
throw new InvalidOperationException("Invalid platform. Can not find proper function");
}
}
[DllImport("libwebp_x86.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncode")]
private static extern int WebPEncode_x86(ref WebPConfig config, ref WebPPicture picture);
[DllImport("libwebp_x64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncode")]
The solution is to 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);
I have an ASP.NET application using .NET Core 3.1 and I'm wondering where I should put the
.dll
files. There is a bin/Release folder in Project.WebApi so, should I add them there?