System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

tomf84
Weird one this.

In a ViewController I call the following code in ViewDidLoad():

AudioSession.Initialize();
AudioSession.Category = AudioSessionCategory.MediaPlayback;
AudioSession.SetActive(true);

Then in response to some button presses I do:

NSError err;
var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
ap.FinishedPlaying += delegate { ap.Dispose(); };
ap.Play();

And this works great, pretty responsive etc.

Except sometimes, seemingly randomly, I get the following unhandled
exception in release mode on the device (iPhone 3GS):

System.MissingMethodException: No constructor found for
MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

Any ideas? Google comes up blank for that specific missing constructor.

Thanks
Tom

--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

tomf84
I have a stack trace for this now - happens in the iPhone Simulator
with debug-mode code too:

  at System.Activator.CreateInstance (System.Type type, BindingFlags
bindingAttr, System.Reflection.Binder binder, System.Object[] args,
System.Globalization.CultureInfo culture, System.Object[]
activationAttributes) [0x000f1] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:280
  at System.Activator.CreateInstance (System.Type type,
System.Object[] args, System.Object[] activationAttributes) [0x00000]
in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234
  at System.Activator.CreateInstance (System.Type type,
System.Object[] args) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr,
IntPtr klass) [0x0000d] in
/Users/plasma/Source/iphone/monotouch/ObjCRuntime/Runtime.cs:154
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x0001f]
in /Users/plasma/Source/iphone/monotouch/ObjCRuntime/Runtime.cs:197
  at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr)
[0x00000] in /Users/plasma/Source/iphone/monotouch/ObjCRuntime/Runtime.cs:214
  at (wrapper native-to-managed)
MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr)
  at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain
(int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args,
System.String principalClassName, System.String delegateClassName)
[0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args)
[0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31
  at MyNamespace.Application.Main (System.String[] args) [0x00016] in
/Users/tf/Projects/MyApp/trunk/MyGuiProject/Main.cs:25

On Mon, Jul 18, 2011 at 11:18 PM, Tom Fanning <[hidden email]> wrote:

> Weird one this.
>
> In a ViewController I call the following code in ViewDidLoad():
>
> AudioSession.Initialize();
> AudioSession.Category = AudioSessionCategory.MediaPlayback;
> AudioSession.SetActive(true);
>
> Then in response to some button presses I do:
>
> NSError err;
> var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
> ap.FinishedPlaying += delegate { ap.Dispose(); };
> ap.Play();
>
> And this works great, pretty responsive etc.
>
> Except sometimes, seemingly randomly, I get the following unhandled
> exception in release mode on the device (iPhone 3GS):
>
> System.MissingMethodException: No constructor found for
> MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)
>
> Any ideas? Google comes up blank for that specific missing constructor.
>
> Thanks
> Tom
>
> --
> Tom Fanning
>



--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

David Moles
In reply to this post by tomf84
FWIW, I'm using AVAudioPlayer.FromUrl() and it works for me. I'm not disposing on FinishedPlaying, though, I've got separate code that calls Stop and then Dispose. I'm also not using AudioSession at all.

Note though that I'm still on MT 3.2.x, if that makes a difference.

On Mon, Jul 18, 2011 at 3:18 PM, Tom Fanning <[hidden email]> wrote:
Weird one this.

In a ViewController I call the following code in ViewDidLoad():

AudioSession.Initialize();
AudioSession.Category = AudioSessionCategory.MediaPlayback;
AudioSession.SetActive(true);

Then in response to some button presses I do:

NSError err;
var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
ap.FinishedPlaying += delegate { ap.Dispose(); };
ap.Play();

And this works great, pretty responsive etc.

Except sometimes, seemingly randomly, I get the following unhandled
exception in release mode on the device (iPhone 3GS):

System.MissingMethodException: No constructor found for
MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

Any ideas? Google comes up blank for that specific missing constructor.

Thanks
Tom

--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch



--
David Moles

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

Anita H.
In reply to this post by tomf84
I've run into the System.MissingMethodException before, in other contexts, and it was always because the method in question was in a dll older than the dll that my application was built with. Hope that helps!
Anita Hirth
Creative and Technical Director
Smart Cookie Studios
Website   Twitter   Facebook   Blog
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

tomf84
In reply to this post by David Moles
Okay, I think I've got this reliable - at least it's not crashed with
150+ button pushes on my last few goes.

For reference

The AudioSession code is required to get volume control working.
Without that, my volume buttons change the ringer volume, not the
media volume.

I have to call AudioSession.SetActive(true); every time I create an
AVAudioPlayer, otherwise I risk an AudioSessionException with message
"Application Audio Session is not active".

I removed the anonymous method from FinishedPlaying, and instead do
the following.

I have a class-scoped List<AVAudioPlayer> called toDispose.

On button press:

{
    // call Play on a freshly instantiated AVAudioPlayer ap:
    var ap = AVAudioPlayer.FromUrl(url, out err);
    ap.Play();

    // next I check to see if toDispose has a bunch of AVAudioPlayers
piled up, and if so, dispose all but the last couple in the list (my
samples are only 0.15 seconds long so it's unlikely I'll dispose one
that's currently playing this way)
    // code snipped for brevity

    // add the current AVAudioPlayer to the list of players to keep track of
    toDispose.Add(ap);
}

then finally in ViewWillDisappear() I dispose any remaining
AVAudioPlayers in toDispose, and remove the disposed player from the
list.

Horrible but stable with many short samples being played, unlike the
sample code on the MonoTouch website.

Thanks for the suggestions.
Tom

On Tue, Jul 19, 2011 at 1:07 AM, David Moles <[hidden email]> wrote:

> FWIW, I'm using AVAudioPlayer.FromUrl() and it works for me. I'm not
> disposing on FinishedPlaying, though, I've got separate code that calls Stop
> and then Dispose. I'm also not using AudioSession at all.
> Note though that I'm still on MT 3.2.x, if that makes a difference.
>
> On Mon, Jul 18, 2011 at 3:18 PM, Tom Fanning <[hidden email]> wrote:
>>
>> Weird one this.
>>
>> In a ViewController I call the following code in ViewDidLoad():
>>
>> AudioSession.Initialize();
>> AudioSession.Category = AudioSessionCategory.MediaPlayback;
>> AudioSession.SetActive(true);
>>
>> Then in response to some button presses I do:
>>
>> NSError err;
>> var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
>> ap.FinishedPlaying += delegate { ap.Dispose(); };
>> ap.Play();
>>
>> And this works great, pretty responsive etc.
>>
>> Except sometimes, seemingly randomly, I get the following unhandled
>> exception in release mode on the device (iPhone 3GS):
>>
>> System.MissingMethodException: No constructor found for
>> MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)
>>
>> Any ideas? Google comes up blank for that specific missing constructor.
>>
>> Thanks
>> Tom
>>
>> --
>> Tom Fanning
>> _______________________________________________
>> MonoTouch mailing list
>> [hidden email]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> --
> David Moles
> [hidden email]
>



--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

Mark Smith
Hi Tom,

I had similar problems with that code fragment, I had to use AVAudioPlayer for exactly the same reason (volume control) and found that some combination of the GC, creating additional objects and my handling of the FinishedPlaying event would cause the same crash.  I only have 5 sounds I play so I finally ended up punting on the issue and holding hard references to each of the players for the lifetime of the application (as I play the sounds periodically throughout).  That solved my problem.

mark

Mark Smith

___________________________________________________

.NET Solutions Mentor & Consultant
DEVELOPMENTOR Instructor and Course Author         

http://www.julmar.com   Twitter: marksm
Blog: http://www.julmar.com/blog/mark
___________________________________________________






On Jul 19, 2011, at 5:28 AM, Tom Fanning wrote:

Okay, I think I've got this reliable - at least it's not crashed with
150+ button pushes on my last few goes.

For reference

The AudioSession code is required to get volume control working.
Without that, my volume buttons change the ringer volume, not the
media volume.

I have to call AudioSession.SetActive(true); every time I create an
AVAudioPlayer, otherwise I risk an AudioSessionException with message
"Application Audio Session is not active".

I removed the anonymous method from FinishedPlaying, and instead do
the following.

I have a class-scoped List<AVAudioPlayer> called toDispose.

On button press:

{
   // call Play on a freshly instantiated AVAudioPlayer ap:
   var ap = AVAudioPlayer.FromUrl(url, out err);
   ap.Play();

   // next I check to see if toDispose has a bunch of AVAudioPlayers
piled up, and if so, dispose all but the last couple in the list (my
samples are only 0.15 seconds long so it's unlikely I'll dispose one
that's currently playing this way)
   // code snipped for brevity

   // add the current AVAudioPlayer to the list of players to keep track of
   toDispose.Add(ap);
}

then finally in ViewWillDisappear() I dispose any remaining
AVAudioPlayers in toDispose, and remove the disposed player from the
list.

Horrible but stable with many short samples being played, unlike the
sample code on the MonoTouch website.

Thanks for the suggestions.
Tom

On Tue, Jul 19, 2011 at 1:07 AM, David Moles <[hidden email]> wrote:
FWIW, I'm using AVAudioPlayer.FromUrl() and it works for me. I'm not
disposing on FinishedPlaying, though, I've got separate code that calls Stop
and then Dispose. I'm also not using AudioSession at all.
Note though that I'm still on MT 3.2.x, if that makes a difference.

On Mon, Jul 18, 2011 at 3:18 PM, Tom Fanning <[hidden email]> wrote:

Weird one this.

In a ViewController I call the following code in ViewDidLoad():

AudioSession.Initialize();
AudioSession.Category = AudioSessionCategory.MediaPlayback;
AudioSession.SetActive(true);

Then in response to some button presses I do:

NSError err;
var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
ap.FinishedPlaying += delegate { ap.Dispose(); };
ap.Play();

And this works great, pretty responsive etc.

Except sometimes, seemingly randomly, I get the following unhandled
exception in release mode on the device (iPhone 3GS):

System.MissingMethodException: No constructor found for
MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

Any ideas? Google comes up blank for that specific missing constructor.

Thanks
Tom

--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch



--
David Moles
[hidden email]




--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: System.MissingMethodException: No constructor found for MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)

tomf84
Cheers. In effect I guess we're doing much the same thing to work
around this issue.

This is now Bug 23.

http://bugzilla.xamarin.com/show_bug.cgi?id=23

Tom

On Tue, Jul 19, 2011 at 2:08 PM, Mark Smith <[hidden email]> wrote:

> Hi Tom,
> I had similar problems with that code fragment, I had to use AVAudioPlayer
> for exactly the same reason (volume control) and found that some combination
> of the GC, creating additional objects and my handling of the
> FinishedPlaying event would cause the same crash.  I only have 5 sounds I
> play so I finally ended up punting on the issue and holding hard references
> to each of the players for the lifetime of the application (as I play the
> sounds periodically throughout).  That solved my problem.
> mark
>
> Mark Smith
>
> ___________________________________________________
>
> .NET Solutions Mentor & Consultant
> DEVELOPMENTOR Instructor and Course Author
>
> http://www.julmar.com   Twitter: marksm
> Blog: http://www.julmar.com/blog/mark
> ___________________________________________________
>
>
>
>
> On Jul 19, 2011, at 5:28 AM, Tom Fanning wrote:
>
> Okay, I think I've got this reliable - at least it's not crashed with
> 150+ button pushes on my last few goes.
>
> For reference
>
> The AudioSession code is required to get volume control working.
> Without that, my volume buttons change the ringer volume, not the
> media volume.
>
> I have to call AudioSession.SetActive(true); every time I create an
> AVAudioPlayer, otherwise I risk an AudioSessionException with message
> "Application Audio Session is not active".
>
> I removed the anonymous method from FinishedPlaying, and instead do
> the following.
>
> I have a class-scoped List<AVAudioPlayer> called toDispose.
>
> On button press:
>
> {
>    // call Play on a freshly instantiated AVAudioPlayer ap:
>    var ap = AVAudioPlayer.FromUrl(url, out err);
>    ap.Play();
>
>    // next I check to see if toDispose has a bunch of AVAudioPlayers
> piled up, and if so, dispose all but the last couple in the list (my
> samples are only 0.15 seconds long so it's unlikely I'll dispose one
> that's currently playing this way)
>    // code snipped for brevity
>
>    // add the current AVAudioPlayer to the list of players to keep track of
>    toDispose.Add(ap);
> }
>
> then finally in ViewWillDisappear() I dispose any remaining
> AVAudioPlayers in toDispose, and remove the disposed player from the
> list.
>
> Horrible but stable with many short samples being played, unlike the
> sample code on the MonoTouch website.
>
> Thanks for the suggestions.
> Tom
>
> On Tue, Jul 19, 2011 at 1:07 AM, David Moles <[hidden email]>
> wrote:
>
> FWIW, I'm using AVAudioPlayer.FromUrl() and it works for me. I'm not
>
> disposing on FinishedPlaying, though, I've got separate code that calls Stop
>
> and then Dispose. I'm also not using AudioSession at all.
>
> Note though that I'm still on MT 3.2.x, if that makes a difference.
>
> On Mon, Jul 18, 2011 at 3:18 PM, Tom Fanning <[hidden email]> wrote:
>
> Weird one this.
>
> In a ViewController I call the following code in ViewDidLoad():
>
> AudioSession.Initialize();
>
> AudioSession.Category = AudioSessionCategory.MediaPlayback;
>
> AudioSession.SetActive(true);
>
> Then in response to some button presses I do:
>
> NSError err;
>
> var ap = AVAudioPlayer.FromUrl(new NSUrl("mysound.caf"), out err);
>
> ap.FinishedPlaying += delegate { ap.Dispose(); };
>
> ap.Play();
>
> And this works great, pretty responsive etc.
>
> Except sometimes, seemingly randomly, I get the following unhandled
>
> exception in release mode on the device (iPhone 3GS):
>
> System.MissingMethodException: No constructor found for
>
> MonoTouch.AVFoundation.InternalAVAudioPlayerDelegate::.ctor(System.IntPtr)
>
> Any ideas? Google comes up blank for that specific missing constructor.
>
> Thanks
>
> Tom
>
> --
>
> Tom Fanning
>
> _______________________________________________
>
> MonoTouch mailing list
>
> [hidden email]
>
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> --
>
> David Moles
>
> [hidden email]
>
>
>
>
> --
> Tom Fanning
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>



--
Tom Fanning
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch