Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
AnswerRe: Read strings between delimiters Pin
Guffa21-Apr-06 12:55
Guffa21-Apr-06 12:55 
AnswerRe: Read strings between delimiters Pin
sujithkumarsl22-Apr-06 16:47
sujithkumarsl22-Apr-06 16:47 
QuestionHaving a max line count in a list control Pin
BambooMoon21-Apr-06 11:25
BambooMoon21-Apr-06 11:25 
AnswerRe: Having a max line count in a list control Pin
Ravi Bhavnani21-Apr-06 11:30
professionalRavi Bhavnani21-Apr-06 11:30 
QuestionObserver Pattern Pin
martin_hughes21-Apr-06 11:07
martin_hughes21-Apr-06 11:07 
AnswerRe: Observer Pattern Pin
Ravi Bhavnani21-Apr-06 11:26
professionalRavi Bhavnani21-Apr-06 11:26 
GeneralRe: Observer Pattern Pin
martin_hughes21-Apr-06 11:51
martin_hughes21-Apr-06 11:51 
General64 bit / IME / WindowsHook problem Pin
Daniel Grunwald21-Apr-06 10:11
Daniel Grunwald21-Apr-06 10:11 
I need help with a strange problem.
Symptom: my C# application crashes with a AccessViolationException. The interesting thing is that it happens only when running as 32bit-process on 64-bit Windows. Running 32bit on 32bit works fine, so does 64bit on 64bit.
FxCop does not complain about my P/Invoke declarations, so I don't think I confused IntPtr and int parameters - it runs fine both as 32bit process and 64bit process - just not as 32 bit process on Windows XP Professional x64 Edition.
Using the managed debug assistent in VS05, I get the error message "The runtime has encountered a fatal error. The address of the error was at 0x79fccc04, on thread 0x6c8. The error code is 0xc0000005.".

The line where it's failing is "return CallNextHookEx(...);", the callstack suggests it fails while/after calling CallNextHookEx; not when returning from my own hook procedure. What makes this really interesting is that the code using the hook is working fine until the text-editor portion of the app is activated. It crashes when the hook receives the message caused by activating the IME (input method editor; for asian languages).

Here is the P/Invoke declaration for the hook (I'm creating the hook with code=WH_CALLWNDPROCRET, hInstance=IntPtr.Zero and threadID=AppDomain.GetCurrentThreadId()):

internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
internal static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
[DllImport("user32.dll")]
internal static extern int UnhookWindowsHookEx(IntPtr hhook);
[DllImport("user32.dll")]
internal static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);

CallNextHookEx[^] definition from MSDN:
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);

And here is the P/Invoke declaration for the IME:
private const int WM_IME_CONTROL = 0x0283;
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, [In, MarshalAs(UnmanagedType.LPStruct)] LOGFONT lParam);
[ StructLayout(LayoutKind.Sequential) ]
private class LOGFONT
{
public int lfHeight = 0;
public int lfWidth = 0;
public int lfEscapement = 0;
public int lfOrientation = 0;
public int lfWeight = 0;
public byte lfItalic = 0;
public byte lfUnderline = 0;
public byte lfStrikeOut = 0;
public byte lfCharSet = 0;
public byte lfOutPrecision = 0;
public byte lfClipPrecision = 0;
public byte lfQuality = 0;
public byte lfPitchAndFamily = 0;
[ MarshalAs(UnmanagedType.ByValTStr, SizeConst=32) ] public string lfFaceName = null;
}

So, how could I find what the problem is? Are there any other tools for checking such problems? I don't have any idea what can I do now. We need to run as 32bit on 64bit Windows because a library used by another part of the app is available for 32bit only.
GeneralRe: 64 bit / IME / WindowsHook problem Pin
LongRange.Shooter21-Apr-06 15:02
LongRange.Shooter21-Apr-06 15:02 
GeneralRe: 64 bit / IME / WindowsHook problem Pin
Daniel Grunwald22-Apr-06 2:06
Daniel Grunwald22-Apr-06 2:06 
QuestionSwitching from DG tp DGV !!!???!!!???!!!??? Pin
mrkeivan21-Apr-06 9:44
mrkeivan21-Apr-06 9:44 
AnswerRe: Switching from DG tp DGV !!!???!!!???!!!??? Pin
Josh Smith21-Apr-06 10:04
Josh Smith21-Apr-06 10:04 
QuestionHow to find what file/s was selected by mouse? Pin
FocusedWolf21-Apr-06 8:35
FocusedWolf21-Apr-06 8:35 
AnswerRe: How to find what file/s was selected by mouse? Pin
Paul Brower21-Apr-06 10:14
Paul Brower21-Apr-06 10:14 
AnswerRe: How to find what file/s was selected by mouse? Pin
John C. Doe21-Apr-06 14:09
John C. Doe21-Apr-06 14:09 
AnswerRe: How to find what file/s was selected by mouse? Pin
John C. Doe21-Apr-06 14:11
John C. Doe21-Apr-06 14:11 
QuestionUsing CollectionBase Pin
JuanAlbertoMD21-Apr-06 8:06
JuanAlbertoMD21-Apr-06 8:06 
AnswerRe: Using CollectionBase Pin
Josh Smith21-Apr-06 10:09
Josh Smith21-Apr-06 10:09 
QuestionHow to add textbox or combobox to toolbar Pin
pliu_200021-Apr-06 7:40
pliu_200021-Apr-06 7:40 
AnswerRe: How to add textbox or combobox to toolbar Pin
Ravi Bhavnani21-Apr-06 8:13
professionalRavi Bhavnani21-Apr-06 8:13 
QuestionEnumerating CD/DVD Drives Pin
Joel Holdsworth21-Apr-06 6:34
Joel Holdsworth21-Apr-06 6:34 
AnswerRe: Enumerating CD/DVD Drives Pin
Paul Brower21-Apr-06 7:38
Paul Brower21-Apr-06 7:38 
QuestionCreating, Showing, Returning values with Windows Forms. Pin
RanvA21-Apr-06 6:26
RanvA21-Apr-06 6:26 
AnswerRe: Creating, Showing, Returning values with Windows Forms. Pin
Zultan21-Apr-06 7:02
Zultan21-Apr-06 7:02 
GeneralRe: Creating, Showing, Returning values with Windows Forms. Pin
RanvA21-Apr-06 7:06
RanvA21-Apr-06 7:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.