Hi,

My custom control use some p/Invoke that are in coredll.dll.

One of this call is done each time the control render. It works fine when
running, but Visual Studio crash when I add the control to a form using the
designer, telling me that the coredll.dll is not find.

How can I prevent that ?
I've added DesktopCompatible = true is the xmta file but it does not work.

Thanks,
Steve

Re: Custom and P/Invoke pb by Tim

Tim
Mon Jan 16 09:51:03 CST 2006

You have a few choices here...

(1) If you need to be able to make the appropriate p/invoke call within the
designer then you can do something like this.

[DllImport("User32", EntryPoint="GetCapture")]
private static extern IntPtr GetCaptureWin();
[DllImport("Coredll", EntryPoint="GetCapture")]
private static extern IntPtr GetCaptureWinCE();

...

IntPtr hWnd;

if (Environment.OSVersion.Platform == PlatformID.WinCE)
{
hWnd = GetCaptureWinCE();
}
else
{
hWnd = GetCaptureWin();
}

(2) If you don't need to be able to make the appropriate p/invoke call
within the designer then you can either check the Platform and only execute
the code if your running on WinCE, as above but ignoring the "else", or you
can wrap the p/invoke in a try...catch.

try
{
// Device specific code.
}
catch
{
}

--
Tim Wilson
.NET Compact Framework MVP

"Steve B." <steve_beauge@com.msn_swap_com_and_msn> wrote in message
news:Oxn63vqGGHA.3532@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> My custom control use some p/Invoke that are in coredll.dll.
>
> One of this call is done each time the control render. It works fine when
> running, but Visual Studio crash when I add the control to a form using
the
> designer, telling me that the coredll.dll is not find.
>
> How can I prevent that ?
> I've added DesktopCompatible = true is the xmta file but it does not work.
>
> Thanks,
> Steve
>
>



Re: Custom and P/Invoke pb by Steve

Steve
Mon Jan 16 10:04:21 CST 2006

Thanks,

I just add the test before the call to the api, in order to disable it on
desktop.
It works fine.

Thanks,
Steve

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> a écrit dans le
message de news: OhYVbSrGGHA.1676@TK2MSFTNGP09.phx.gbl...
> You have a few choices here...
>
> (1) If you need to be able to make the appropriate p/invoke call within
> the
> designer then you can do something like this.
>
> [DllImport("User32", EntryPoint="GetCapture")]
> private static extern IntPtr GetCaptureWin();
> [DllImport("Coredll", EntryPoint="GetCapture")]
> private static extern IntPtr GetCaptureWinCE();
>
> ...
>
> IntPtr hWnd;
>
> if (Environment.OSVersion.Platform == PlatformID.WinCE)
> {
> hWnd = GetCaptureWinCE();
> }
> else
> {
> hWnd = GetCaptureWin();
> }
>
> (2) If you don't need to be able to make the appropriate p/invoke call
> within the designer then you can either check the Platform and only
> execute
> the code if your running on WinCE, as above but ignoring the "else", or
> you
> can wrap the p/invoke in a try...catch.
>
> try
> {
> // Device specific code.
> }
> catch
> {
> }
>
> --
> Tim Wilson
> .NET Compact Framework MVP
>
> "Steve B." <steve_beauge@com.msn_swap_com_and_msn> wrote in message
> news:Oxn63vqGGHA.3532@TK2MSFTNGP14.phx.gbl...
>> Hi,
>>
>> My custom control use some p/Invoke that are in coredll.dll.
>>
>> One of this call is done each time the control render. It works fine when
>> running, but Visual Studio crash when I add the control to a form using
> the
>> designer, telling me that the coredll.dll is not find.
>>
>> How can I prevent that ?
>> I've added DesktopCompatible = true is the xmta file but it does not
>> work.
>>
>> Thanks,
>> Steve
>>
>>
>
>