ObjC-C# binding, native 'init' returns nil
pburgio opened this issue · 1 comments
Hello,
I am extending the Xamarin. SoupChef example to implement my own Intent. I correctly generated the library following the example in SoupChef, but when I try to reference it in the app (I am using the SoupChef app), i receive the following error:
Could not initialize an instance of the type 'SoupChef.SendCommandIntent': the native 'init' method returned nil.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
I checked all the steps to generate the library, and including it in the original SoupChef.OrderSoupIntentBinding, including registering the intents in its Info.plist. But when it comes to using it, i get the error. Some code follows
// Order.cs
public OrderSoupIntent Intent
{
get
{
*var myIntent = new SendCommandIntent(); // Only added this line!!!*
var orderSoupIntent = new OrderSoupIntent();
orderSoupIntent.Quantity = new NSNumber(Quantity);
orderSoupIntent.Soup = new INObject(MenuItem.ItemNameKey, MenuItem.LocalizedString);
Exception is thrown here (file SendCommandIntent.g.cs)
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
[Export ("init")]
public SendCommandIntent () : base (NSObjectFlag.Empty)
{
IsDirectBinding = GetType ().Assembly == global::ApiDefinitions.Messaging.this_assembly;
if (IsDirectBinding) {
HERE--> InitializeHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("init")), "init");
} else {
InitializeHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSendSuper (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("init")), "init");
}
}
Can anyone help me please?
Paolo
Hello I finally solved it. I forgot to update the Intent.intentdefinition file in the Binding project
Cheers
Paolo