HandyControl icon indicating copy to clipboard operation
HandyControl copied to clipboard

选择 VS x86环境,运行代码报错 对 PInvoke 函数“HandyControl!HandyControl.Tools.Interop.InteropMethods::GetWindowPlacement”的调用导致堆栈不对称。

Open Anonymy opened this issue 2 years ago • 3 comments

Describe the bug

VS .NET 4.5 4.6环境 ,V3.4.0版本、最新master分支代码,生成选择x86环境运行代码报错: 对 PInvoke 函数“HandyControl!HandyControl.Tools.Interop.InteropMethods::GetWindowPlacement”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。

VS .NET6环境运行没有上述问题,master分支看记录有解决这个问题,似乎没有彻底解决。请作者再看看~

Steps to reproduce the bug

VS .NET 4.5 4.6环境 ,V3.4.0版本、最新master分支代码,生成选择x86环境运行代码报错:

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.4.0

IDE

Visual Studio 2019

Framework type

.Net Framework 4.5.0

Windows version

No response

Additional context

No response

Anonymy avatar Aug 03 '23 01:08 Anonymy

我修改了三处 [Serializable] <-1--添加 [StructLayout(LayoutKind.Sequential)] internal struct WINDOWPLACEMENT

2--->加了个ref

private static extern bool GetWindowPlacement(IntPtr hwnd, ref InteropValues.WINDOWPLACEMENT lpwndpl);

3--->加了个ref if (GetWindowPlacement(hwnd, ref wINDOWPLACEMENT))

rebuild后不会报错了 环境,vs2019, 之前直接运行不会报错,但在vs2019中debug运行就会报此错误,如上修改后运行正常

nickmxtsky avatar Aug 04 '23 03:08 nickmxtsky

3.4.0版本有这个问题。换成3.3.0版本就没有这个问题了。 issue

Sky-shang avatar Aug 15 '23 02:08 Sky-shang

我也遇到这个问题,我提交了一个解决办法,可以测试一下。 #1419

asine avatar Oct 04 '23 07:10 asine

dc50859ceee4af9e649ec341de90eca9cbf737cb

NaBian avatar Mar 07 '24 04:03 NaBian