-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception thrown 'Unable to find an entry point named 'CopyMemory' in DLL 'kernel32.dll'.' on WPF project with .NET Core 3.0 #12496
Comments
From @vatsan-madhavan on Monday, 15 April 2019 19:44:57 This doesn't seem specific to WPF. Happens in a general .NET Core application as well. using System;
using System.Runtime.InteropServices;
namespace test1
{
class Program
{
static void Main(string[] args)
{
bool val = false;
try
{
const int size = 200;
IntPtr memorySource = Marshal.AllocHGlobal(size);
Marshal.WriteInt32(memorySource, 35);
IntPtr memoryTarget = Marshal.AllocHGlobal(size);
CopyMemory(memoryTarget, memorySource, size);
val = Marshal.ReadInt32(memoryTarget) == 35;
}
catch(EntryPointNotFoundException e)
{
Console.WriteLine(e.ToString());
}
Console.WriteLine($"Successfully read from CopyMemory ? : {val}");
}
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)]
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
}
}
@AaronRobinsonMSFT, should be this be moved to coreclr? |
From @AaronRobinsonMSFT on Monday, 15 April 2019 20:51:42 @vatsan-madhavan This is failing for an absolutely insane reason. There are no words for the nonsense.. Feel free to push this issue over to CoreCLR and mark it as 3.0. |
From @AaronRobinsonMSFT on Monday, 15 April 2019 22:00:59 I didn't realize this was just reported via WPF. @Ebenezer94 In .NET Framework there was a special case for a few function names and |
@Ebenezer94 As an FYI, there were a few special cased P/Invoke names in .NET Framework: |
BTW, @AaronRobinsonMSFT asked me offline whether this affects the WPF codebase itself. The answer is no. We looked through the P/Invokes in the codebase, and found that the P/Invoke for |
.Net could fails with exception "Unable to find an entry point named 'CopyMemory' in DLL 'kernel32.dll`" as the export doesn't exist see reference https://github.com/dotnet/coreclr/issues/24008 Issue #2053
From @Ebenezer94 on Monday, 15 April 2019 17:50:37
We have used the CopyMemory method in our project to copies memory from source to destination. While copying, exception thrown like "'Unable to find an entry point named 'CopyMemory' in DLL 'kernel32.dll'.'". This code works fine in WPF with .NET Framework. But, we are facing an issue in WPF with .NET Core. I have added the simple code snippet to reproduce the issue in WPF with .NETCore. The simple sample can be download from below link,
.NET Core3.0
http://www.syncfusion.com/downloads/support/directtrac/general/ze/NETCOR~1263359629.zip
.NET Framework
http://www.syncfusion.com/downloads/support/directtrac/general/ze/CopyMemory_NetFramework542091517.zip
Code snippet :
Please find the required configuration below.
.NET Framework : 4.6
.NET Core : 3.0
Operating System : Windows 10
Preferred Programming Language : C#
Visual Studio : Visual Studio 2017
Copied from original issue: dotnet/wpf#586
The text was updated successfully, but these errors were encountered: