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

Re: DLLImport Breaks Designer in VS2005 by ctacke/>

ctacke/>
Wed Sep 13 21:07:24 CDT 2006

The desktop has no idea what coredll.dll is, so the designer assembly must
be told something about it. Controls aren't my specialty, but IIRC there's
an attribute you set for desktop compatibility to get it to work.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Craig" <Craig@discussions.microsoft.com> wrote in message
news:D8476484-77D5-4ED7-92C1-0B2FDFFFA743@microsoft.com...
> 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



Re: DLLImport Breaks Designer in VS2005 by Craig

Craig
Thu Sep 14 07:52:02 CDT 2006

I will try in the class attributes... I didn't think I had too because it was
a private method. I do agree with you say... the designer doesn't know it so
it gets confused. I even tried moving the dll import into a class object
that is used by the control, but I got the same results. I guess it is still
part of the control in the end and it still doesn't like it.

I will try to somehow hide it from designer... if anyone has any ideas,
please let me know. Thanks!

- Craig

"<ctacke/>" wrote:

> The desktop has no idea what coredll.dll is, so the designer assembly must
> be told something about it. Controls aren't my specialty, but IIRC there's
> an attribute you set for desktop compatibility to get it to work.
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Craig" <Craig@discussions.microsoft.com> wrote in message
> news:D8476484-77D5-4ED7-92C1-0B2FDFFFA743@microsoft.com...
> > 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
>
>
>