
我缩小了我的p / invoke PeekMessage调用.所以,我需要这里的辉煌的头脑,看看我写的废话,告诉我,如果我做的正确.因为,认真的,我即将失去我的国王心灵.我已经在2台电脑上试过了,他们都表现出相同的行为.我有点担心这可能是.NET 4.0的错误.
无论如何,这是我的p / invoke代码.请让我知道,如果你看到任何奇怪或只是平淡无奇:
这是PeekMessage的电话:
@H_404_8@private static bool PeekMessage(){ MSG message = new MSG(); // Message to retrIEve. return Win32API.PeekMessage(ref message,IntPtr.Zero,PeekMessageFlags.noremove);}这里是PeekMessage(注意:抑制安全属性在类定义上,因此正在应用):
@H_404_8@[return: MarshalAs(UnmanagedType.Bool)][Dllimport("User32.dll",CharSet=CharSet.auto)]public static extern bool PeekMessage(ref MSG msg,IntPtr hwnd,uint wFilterMin,uint wFilterMax,PeekMessageFlags flags);这是MSG:
@H_404_8@[StructLayout(LayoutKind.Sequential)]internal struct MSG{ /// <summary>Window handle.</summary> public IntPtr hwnd; /// <summary>Message to process.</summary> public uint Message; /// <summary>Window message parameter 1.</summary> public uint wParam; /// <summary>Window message parameter 2.</summary> public uint lParam; /// <summary>Time message was sent?</summary> public uint time; /// <summary>Mouse pointer position.</summary> public Point pt;}最后,PeekMessageFlags:
@H_404_8@internal enum PeekMessageFlags{ /// <summary>Keep message on the message queue.</summary> noremove = 0,/// <summary>Remove message from the queue.</summary> Remove = 1,/// <summary>Do not yIEld execution to waiting threads.</summary> NoYIEld = 2}我检查了事件日志,我得到了:
@H_404_8@Faulting application name: Tester_Graphics.exe,version: 1.0.0.0,time stamp: 0x4ec0ba85Faulting module name: unkNown,version: 0.0.0.0,time stamp: 0x00000000Exception code: 0xc0000005Fault offset: 0x00000000000001cbFaulting process ID: 0x1260Faulting application start time: 0x01cca299e2c21a77Faulting application path: D:\Code\Current\Gorgon\Branches\2.x\Dorian\Examples\Tester_Graphics\bin\Release\Tester_Graphics.exeFaulting module path: unkNownReport ID: 20ac891f-0e8d-11e1-a5d7-bcaec5753ddd所以,如果你看到不正确的事情,请让我知道.我讨厌这不是我的错.
对不起,如果它不够详细,如果你需要更多的信息,只要留言.
解决方法 MSG的lParam和wParam字段的大小是错误的.你应该使用IntPtr而不是uint / int.如果你看看Windows Data Types你可以看到:
> LParaM是一个LONG_PTR,即32位平台的32位,64位平台上的64位.
> ParaM是一个UINT_PTR,它在32位平台上大小为32位,64位平台的大小为64位.
相反,int和uint类型都是32位大小,无论平台如何,这意味着在64位平台上,您的MSG结构体的64位太小,这将导致某种内存损坏.
总结以上是内存溢出为你收集整理的c# – 仅在IDE之外的发行模式下使用x64 .NET 4.0应用程序崩溃全部内容,希望文章能够帮你解决c# – 仅在IDE之外的发行模式下使用x64 .NET 4.0应用程序崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)