PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Custom and P/Invoke pb

Reply

Custom and P/Invoke pb

 
Thread Tools Rate Thread
Old 16-01-2006, 02:48 PM   #1
Steve B.
Guest
 
Posts: n/a
Default Custom and P/Invoke pb


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


  Reply With Quote
Old 16-01-2006, 03:51 PM   #2
Tim Wilson
Guest
 
Posts: n/a
Default Re: Custom and P/Invoke pb

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
>
>



  Reply With Quote
Old 16-01-2006, 04:04 PM   #3
Steve B.
Guest
 
Posts: n/a
Default Re: Custom and P/Invoke pb

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
>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off