Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default constructor not found of type'MyClass'

I am trying to render a custom view from from xamarin.forms. When I try to render it from with following code

[assembly: ExportRenderer(typeof(SwipeableCard),typeof(CardContainer))] .

But an error throws like

default constructor not found of type 'Com.andtinde.CardContainer' .

I guess it is because the card container does not have a default constructor. And I cannot provide one because it inherits from Adapterview.

What I am doing wrong. Any help would be appriciated.

like image 400
Tinku Chacko Avatar asked Mar 17 '15 11:03

Tinku Chacko


1 Answers

Xamarin Forms PCL: System.MissingMethodException: Default constructor not found for type

This will occur normally whenever you used a class for dependency injection or using device-specific classes. You can try it out by debugging. I had faced the same but solved it by giving the current class for typeof property. should not give the service or any other interface name:

[assembly: Xamarin.Forms.Dependency(typeof(Name Of Class))]

and not:

[assembly: Xamarin.Forms.Dependency(typeof(Name Of Interface))]
like image 126
Samithe Adhikari Avatar answered Sep 21 '22 09:09

Samithe Adhikari