Hi All,
Using a DLLImport in a user control prevents it from working in designer.
To reproduce this issue, create a control library... leave the default
control. Create an override for the Paint and have it clear the background
to red.
Next create an application project (need a Form to drag control on to). To
verify your control works, drag it from the tool box... you get a red square.
Now delete it from the Form and add the following to the control:
References:
using System.Reflection;
using System.Runtime.InteropServices;
Code:
[DllImport("coredll.dll")]
private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
uint dwExtraInfo);
Now try dragging the control to the Form after you compile... you get a big
gray square with the name space in it... it no longer draws itself and you
may get different errors if you close and reopen studio with the project.
This is a serious issue. Please help. Is there a fix... am I doing
something wrong? Does anyone get the same behavior?
Thanks in advance,
Craig Buck