I have added the "aygshell" reference to SndPlaySync to my Pocket PC 2003
project using:

[code]
[DllImport("aygshell.dll", SetLastError = true)]
static extern IntPtr SndPlaySync(string Path, uint Flags);
[/code]

In my code, I try calling SndPlaySync using this code:

[code]
IntPtr ip;
if (System.IO.File.Exists(file) == true) {
ip = SndPlaySync(file, 0);
}
[/code]

However, SndPlaySync is throwing this MissingMethodException message:

Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
'aygshell.dll'."

How do I fix this?

Am I calling the SndPlaySync function incorrectly? Is the DLL reference
incorrect? What else could it be?

Re: P/Invoke SndPlaySync EntryPoint? by Peter

Peter
Wed Jun 25 10:43:22 CDT 2008

This API was added in Windows Mobile 6. You can't call it on older devices
as you'll get this error. You can use PlaySound instead but it is limited to
.wav files only.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility

"jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
>I have added the "aygshell" reference to SndPlaySync to my Pocket PC 2003
> project using:
>
> [code]
> [DllImport("aygshell.dll", SetLastError = true)]
> static extern IntPtr SndPlaySync(string Path, uint Flags);
> [/code]
>
> In my code, I try calling SndPlaySync using this code:
>
> [code]
> IntPtr ip;
> if (System.IO.File.Exists(file) == true) {
> ip = SndPlaySync(file, 0);
> }
> [/code]
>
> However, SndPlaySync is throwing this MissingMethodException message:
>
> Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
> 'aygshell.dll'."
>
> How do I fix this?
>
> Am I calling the SndPlaySync function incorrectly? Is the DLL reference
> incorrect? What else could it be?


Re: P/Invoke SndPlaySync EntryPoint? by jp2msft

jp2msft
Wed Jun 25 11:04:04 CDT 2008

Thanks. That goes a long way towards helping me out! :)

"Peter Foot" wrote:

> This API was added in Windows Mobile 6. You can't call it on older devices
> as you'll get this error. You can use PlaySound instead but it is limited to
> .wav files only.
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> peterfoot.net | appamundi.com | inthehand.com
> APPA Mundi Ltd - Software Solutions for a Mobile World
> In The Hand Ltd - .NET Components for Mobility
>
> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
> news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
> >I have added the "aygshell" reference to SndPlaySync to my Pocket PC 2003
> > project using:
> >
> > [code]
> > [DllImport("aygshell.dll", SetLastError = true)]
> > static extern IntPtr SndPlaySync(string Path, uint Flags);
> > [/code]
> >
> > In my code, I try calling SndPlaySync using this code:
> >
> > [code]
> > IntPtr ip;
> > if (System.IO.File.Exists(file) == true) {
> > ip = SndPlaySync(file, 0);
> > }
> > [/code]
> >
> > However, SndPlaySync is throwing this MissingMethodException message:
> >
> > Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
> > 'aygshell.dll'."
> >
> > How do I fix this?
> >
> > Am I calling the SndPlaySync function incorrectly? Is the DLL reference
> > incorrect? What else could it be?
>

Re: P/Invoke SndPlaySync EntryPoint? by jp2msft

jp2msft
Wed Jun 25 11:24:00 CDT 2008

Rats! VS2005 or Pocket PC didn't like that either.

Whenever I call PlaySound (using the technique described here:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/f7f62f53-e026-4c40-b221-3a26adb0c2c5.htm) I also get a MissingMethodException.

This time, the Message is 'Can't find PInvoke DLL "winmm.DLL"'.

Up top, I have:
[System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
"PlaySound", SetLastError = true)]
private static extern bool PlaySound(string szSound, System.IntPtr hMod,
PlaySoundFlags flags);

[System.Flags]
public enum PlaySoundFlags : int {
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_NODEFAULT = 0x0002,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}

In the code:
bool ok = false;
if (System.IO.File.Exists(file) == true) {
try {
ok = PlaySound(file, new System.IntPtr(), PlaySoundFlags.SND_SYNC);
} catch (MissingMethodException mme) {
Console.WriteLine(mme.Message);
} catch (Exception e) {
Console.WriteLine(e.Message);
}
}

I am using a WAV file. Any idea what I could be doing wrong this time?

I'm pretty darned good at doing stuff wrong, by the way! :)

"Peter Foot" wrote:

> This API was added in Windows Mobile 6. You can't call it on older devices
> as you'll get this error. You can use PlaySound instead but it is limited to
> .wav files only.
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> peterfoot.net | appamundi.com | inthehand.com
> APPA Mundi Ltd - Software Solutions for a Mobile World
> In The Hand Ltd - .NET Components for Mobility
>
> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
> news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
> >I have added the "aygshell" reference to SndPlaySync to my Pocket PC 2003
> > project using:
> >
> > [code]
> > [DllImport("aygshell.dll", SetLastError = true)]
> > static extern IntPtr SndPlaySync(string Path, uint Flags);
> > [/code]
> >
> > In my code, I try calling SndPlaySync using this code:
> >
> > [code]
> > IntPtr ip;
> > if (System.IO.File.Exists(file) == true) {
> > ip = SndPlaySync(file, 0);
> > }
> > [/code]
> >
> > However, SndPlaySync is throwing this MissingMethodException message:
> >
> > Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
> > 'aygshell.dll'."
> >
> > How do I fix this?
> >
> > Am I calling the SndPlaySync function incorrectly? Is the DLL reference
> > incorrect? What else could it be?
>

Re: P/Invoke SndPlaySync EntryPoint? by Chris

Chris
Wed Jun 25 12:10:21 CDT 2008

Because it's in coredll.dll, not winmm.dll

-Chris


"jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
news:6811128D-FA47-4CF1-AF71-B2F4D2786A9C@microsoft.com...
> Rats! VS2005 or Pocket PC didn't like that either.
>
> Whenever I call PlaySound (using the technique described here:
> ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/f7f62f53-e026-4c40-b221-3a26adb0c2c5.htm)
> I also get a MissingMethodException.
>
> This time, the Message is 'Can't find PInvoke DLL "winmm.DLL"'.
>
> Up top, I have:
> [System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
> "PlaySound", SetLastError = true)]
> private static extern bool PlaySound(string szSound, System.IntPtr hMod,
> PlaySoundFlags flags);
>
> [System.Flags]
> public enum PlaySoundFlags : int {
> SND_SYNC = 0x0000,
> SND_ASYNC = 0x0001,
> SND_NODEFAULT = 0x0002,
> SND_LOOP = 0x0008,
> SND_NOSTOP = 0x0010,
> SND_NOWAIT = 0x00002000,
> SND_FILENAME = 0x00020000,
> SND_RESOURCE = 0x00040004
> }
>
> In the code:
> bool ok = false;
> if (System.IO.File.Exists(file) == true) {
> try {
> ok = PlaySound(file, new System.IntPtr(), PlaySoundFlags.SND_SYNC);
> } catch (MissingMethodException mme) {
> Console.WriteLine(mme.Message);
> } catch (Exception e) {
> Console.WriteLine(e.Message);
> }
> }
>
> I am using a WAV file. Any idea what I could be doing wrong this time?
>
> I'm pretty darned good at doing stuff wrong, by the way! :)
>
> "Peter Foot" wrote:
>
>> This API was added in Windows Mobile 6. You can't call it on older
>> devices
>> as you'll get this error. You can use PlaySound instead but it is limited
>> to
>> .wav files only.
>>
>> Peter
>>
>> --
>> Peter Foot
>> Microsoft Device Application Development MVP
>> peterfoot.net | appamundi.com | inthehand.com
>> APPA Mundi Ltd - Software Solutions for a Mobile World
>> In The Hand Ltd - .NET Components for Mobility
>>
>> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
>> news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
>> >I have added the "aygshell" reference to SndPlaySync to my Pocket PC
>> >2003
>> > project using:
>> >
>> > [code]
>> > [DllImport("aygshell.dll", SetLastError = true)]
>> > static extern IntPtr SndPlaySync(string Path, uint Flags);
>> > [/code]
>> >
>> > In my code, I try calling SndPlaySync using this code:
>> >
>> > [code]
>> > IntPtr ip;
>> > if (System.IO.File.Exists(file) == true) {
>> > ip = SndPlaySync(file, 0);
>> > }
>> > [/code]
>> >
>> > However, SndPlaySync is throwing this MissingMethodException message:
>> >
>> > Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
>> > 'aygshell.dll'."
>> >
>> > How do I fix this?
>> >
>> > Am I calling the SndPlaySync function incorrectly? Is the DLL reference
>> > incorrect? What else could it be?
>>


Re: P/Invoke SndPlaySync EntryPoint? by jp2msft

jp2msft
Wed Jun 25 13:18:00 CDT 2008

Thanks, Mr. Tacke! That worked.

I can't *believe* Microsoft's Help had a typo in it!

I'm glad they don't make as many mistakes as I do, though.

;)

"Chris Tacke, MVP" wrote:

> Because it's in coredll.dll, not winmm.dll
>
> -Chris
>
>
> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
> news:6811128D-FA47-4CF1-AF71-B2F4D2786A9C@microsoft.com...
> > Rats! VS2005 or Pocket PC didn't like that either.
> >
> > Whenever I call PlaySound (using the technique described here:
> > ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/f7f62f53-e026-4c40-b221-3a26adb0c2c5.htm)
> > I also get a MissingMethodException.
> >
> > This time, the Message is 'Can't find PInvoke DLL "winmm.DLL"'.
> >
> > Up top, I have:
> > [System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
> > "PlaySound", SetLastError = true)]
> > private static extern bool PlaySound(string szSound, System.IntPtr hMod,
> > PlaySoundFlags flags);
> >
> > [System.Flags]
> > public enum PlaySoundFlags : int {
> > SND_SYNC = 0x0000,
> > SND_ASYNC = 0x0001,
> > SND_NODEFAULT = 0x0002,
> > SND_LOOP = 0x0008,
> > SND_NOSTOP = 0x0010,
> > SND_NOWAIT = 0x00002000,
> > SND_FILENAME = 0x00020000,
> > SND_RESOURCE = 0x00040004
> > }
> >
> > In the code:
> > bool ok = false;
> > if (System.IO.File.Exists(file) == true) {
> > try {
> > ok = PlaySound(file, new System.IntPtr(), PlaySoundFlags.SND_SYNC);
> > } catch (MissingMethodException mme) {
> > Console.WriteLine(mme.Message);
> > } catch (Exception e) {
> > Console.WriteLine(e.Message);
> > }
> > }
> >
> > I am using a WAV file. Any idea what I could be doing wrong this time?
> >
> > I'm pretty darned good at doing stuff wrong, by the way! :)
> >
> > "Peter Foot" wrote:
> >
> >> This API was added in Windows Mobile 6. You can't call it on older
> >> devices
> >> as you'll get this error. You can use PlaySound instead but it is limited
> >> to
> >> .wav files only.
> >>
> >> Peter
> >>
> >> --
> >> Peter Foot
> >> Microsoft Device Application Development MVP
> >> peterfoot.net | appamundi.com | inthehand.com
> >> APPA Mundi Ltd - Software Solutions for a Mobile World
> >> In The Hand Ltd - .NET Components for Mobility
> >>
> >> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
> >> news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
> >> >I have added the "aygshell" reference to SndPlaySync to my Pocket PC
> >> >2003
> >> > project using:
> >> >
> >> > [code]
> >> > [DllImport("aygshell.dll", SetLastError = true)]
> >> > static extern IntPtr SndPlaySync(string Path, uint Flags);
> >> > [/code]
> >> >
> >> > In my code, I try calling SndPlaySync using this code:
> >> >
> >> > [code]
> >> > IntPtr ip;
> >> > if (System.IO.File.Exists(file) == true) {
> >> > ip = SndPlaySync(file, 0);
> >> > }
> >> > [/code]
> >> >
> >> > However, SndPlaySync is throwing this MissingMethodException message:
> >> >
> >> > Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
> >> > 'aygshell.dll'."
> >> >
> >> > How do I fix this?
> >> >
> >> > Am I calling the SndPlaySync function incorrectly? Is the DLL reference
> >> > incorrect? What else could it be?
> >>
>

Re: P/Invoke SndPlaySync EntryPoint? by Chris

Chris
Wed Jun 25 13:30:21 CDT 2008

It's not unusual for the docs to have errors, but in this case there isn't
one:

http://msdn.microsoft.com/en-us/library/aa909766.aspx

You were probably looking at the desktop docs for PlaySound.


-Chris


"jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
news:943E1F3C-2540-423E-A6C2-97C4A0DC9645@microsoft.com...
> Thanks, Mr. Tacke! That worked.
>
> I can't *believe* Microsoft's Help had a typo in it!
>
> I'm glad they don't make as many mistakes as I do, though.
>
> ;)
>
> "Chris Tacke, MVP" wrote:
>
>> Because it's in coredll.dll, not winmm.dll
>>
>> -Chris
>>
>>
>> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
>> news:6811128D-FA47-4CF1-AF71-B2F4D2786A9C@microsoft.com...
>> > Rats! VS2005 or Pocket PC didn't like that either.
>> >
>> > Whenever I call PlaySound (using the technique described here:
>> > ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/f7f62f53-e026-4c40-b221-3a26adb0c2c5.htm)
>> > I also get a MissingMethodException.
>> >
>> > This time, the Message is 'Can't find PInvoke DLL "winmm.DLL"'.
>> >
>> > Up top, I have:
>> > [System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
>> > "PlaySound", SetLastError = true)]
>> > private static extern bool PlaySound(string szSound, System.IntPtr
>> > hMod,
>> > PlaySoundFlags flags);
>> >
>> > [System.Flags]
>> > public enum PlaySoundFlags : int {
>> > SND_SYNC = 0x0000,
>> > SND_ASYNC = 0x0001,
>> > SND_NODEFAULT = 0x0002,
>> > SND_LOOP = 0x0008,
>> > SND_NOSTOP = 0x0010,
>> > SND_NOWAIT = 0x00002000,
>> > SND_FILENAME = 0x00020000,
>> > SND_RESOURCE = 0x00040004
>> > }
>> >
>> > In the code:
>> > bool ok = false;
>> > if (System.IO.File.Exists(file) == true) {
>> > try {
>> > ok = PlaySound(file, new System.IntPtr(), PlaySoundFlags.SND_SYNC);
>> > } catch (MissingMethodException mme) {
>> > Console.WriteLine(mme.Message);
>> > } catch (Exception e) {
>> > Console.WriteLine(e.Message);
>> > }
>> > }
>> >
>> > I am using a WAV file. Any idea what I could be doing wrong this time?
>> >
>> > I'm pretty darned good at doing stuff wrong, by the way! :)
>> >
>> > "Peter Foot" wrote:
>> >
>> >> This API was added in Windows Mobile 6. You can't call it on older
>> >> devices
>> >> as you'll get this error. You can use PlaySound instead but it is
>> >> limited
>> >> to
>> >> .wav files only.
>> >>
>> >> Peter
>> >>
>> >> --
>> >> Peter Foot
>> >> Microsoft Device Application Development MVP
>> >> peterfoot.net | appamundi.com | inthehand.com
>> >> APPA Mundi Ltd - Software Solutions for a Mobile World
>> >> In The Hand Ltd - .NET Components for Mobility
>> >>
>> >> "jp2msft" <jp2msft@discussions.microsoft.com> wrote in message
>> >> news:CD217ACB-8861-44B4-A15D-7F705CD736BA@microsoft.com...
>> >> >I have added the "aygshell" reference to SndPlaySync to my Pocket PC
>> >> >2003
>> >> > project using:
>> >> >
>> >> > [code]
>> >> > [DllImport("aygshell.dll", SetLastError = true)]
>> >> > static extern IntPtr SndPlaySync(string Path, uint Flags);
>> >> > [/code]
>> >> >
>> >> > In my code, I try calling SndPlaySync using this code:
>> >> >
>> >> > [code]
>> >> > IntPtr ip;
>> >> > if (System.IO.File.Exists(file) == true) {
>> >> > ip = SndPlaySync(file, 0);
>> >> > }
>> >> > [/code]
>> >> >
>> >> > However, SndPlaySync is throwing this MissingMethodException
>> >> > message:
>> >> >
>> >> > Message="Can't find an Entry Point 'SndPlaySync' in a PInvoke DLL
>> >> > 'aygshell.dll'."
>> >> >
>> >> > How do I fix this?
>> >> >
>> >> > Am I calling the SndPlaySync function incorrectly? Is the DLL
>> >> > reference
>> >> > incorrect? What else could it be?
>> >>
>>