Xamarin.Behaviors with Xamarin.Forms iOS

拜拜、爱过 提交于 2019-12-12 18:54:07

问题


Yesterday, I stuck in a bug relative to Xamarin.Behaviors and Xamarin.Forms. The detail is a Exception was thrown after i add these code line in my xaml page:

 <b:Interaction.Behaviors>
        <b:BehaviorCollection>
        <b:EventToCommand EventName="Clicked" Command="{Binding MyCommand}" />
        </b:BehaviorCollection>
 </b:Interaction.Behaviors>  

Although, I've added this line to xaml namespace

xmlns:b="clr-namespace:Xamarin.Behaviors;assembly=Xamarin.Behaviors"

Application got crash with exception: "Could not load file or assembly 'Xamarin.Behaviors' or one of its dependencies. The system cannot find the file specified."

Specially, It's only happened on iOS, android and wp still work well. So, I guess this could be xamarin bug or xamarin studio bug ...

P/S: I checked that Xamarin.Behaviors existed in package folder in my project, and App still not found where that assembly is


回答1:


To help somebody who also engage this bug. I will post my answer to show my solution for this. Nuget has problem with this lib and we can't use it anymore. I have to forget the Nuget and copy full of class in this library to my project. So, It look like your code which you wrote, not the library. Of course, we have to update this manually instead of use Nuget as before. Maybe, this solution is just temporary. Someone would find better one and I'll change my answer.




回答2:


I faced this issue in building my iOS project so after a lot R&D I added this line of code in my iOS AppDelegate.cs file

Xamarin.Behaviors.Infrastructure.Init ();

That's all I had to do, the above line of code helps the iOS files to forcefully link to some assemblies. Adding the above line resolved my crash.

Hope it helps



来源:https://stackoverflow.com/questions/33115447/xamarin-behaviors-with-xamarin-forms-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!