[Mono-bugs] [Bug 655342] System.InvalidOperationException When Inheriting From IntentService

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 22 16:22:40 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=655342

https://bugzilla.novell.com/show_bug.cgi?id=655342#c3


--- Comment #3 from Dan Russell <danomania at gmail.com> 2010-11-22 13:22:39 PST ---
(In reply to comment #1)
> Background:
>   - Types which are listed within AndroidManifest.xml may be created by
> Android.
>   - Types with the [Activity], [BroadcastReceiver], 
>     [ContentProvider], and [Service] attributes are inserted into the
>     resulting AndroidManifest.xml file.
>   - When Android creates one of these types, the default constructor is
> invoked.
>   - If the default constructor is not present, an error will be thrown and 
>     the app will terminate.

Thanks for the info. Now that I understand the context,...

> Thus, there is a choice here:
> 
>  1. Generate an error if a type listed in AndroidManifest.xml doesn't have
>     a default constructor.  This is the current behavior.
> 
>  2. Allow types with no default constructor to be present within 
>     AndroidManifest.xml, and have Android throw an error later.
> 
> Obviously I like (1), but I'm willing to entertain (2).

I think your preference (1) works nicely. That way, we know about it at compile
time rather having to wait for a runtime error. I tested this in Eclipse. It
lets you compile it but from the logs, the runtime error isn't all that clear.

> As for Android.App.IntentService, the appropriate fix is to either:
> 
>  1. Remove the [Service] attribute from your MyIntentService type; or

This error is generated whether the [Service] attribute is present or not.

>  2. Provide a default constructor, and provide a value to the base constructor:
> 
>     [Service]
>     public MyIntentService : IntentService {
>         public MyIntentService ()
>             : base ("worker-thread-name")
>         {
>         }
>     }

This works for me.
Silly me. Why didn't I think of that?

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list