Xamarin.Forms shared project issue in XAML

I am developing one app in Xamarin.Forms and with shared project template. I added one class reference in XAML like below:

xmlns:common="clr-namespace:MyApp.CommonHelper;assembly=MyApp"-->

Now I can compile and run and code in simulator/emulator. But, while trying to run in actual device it is throwing assembly error.
please let us know what the exact issue and how to resolve that.

Posts

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    Chances are that the linker removes the code you're trying to access (hard to say without seeing the actual exception...)

    Different ways of solving this:

    • Add a dummy method into the library/code you are using (a static one) and call it so the code you have in there is actually used and the linker won't remove it. You can see an example of such a method here
    • On iOS, you can use the PreserveAttribute to prevent the linker from removing code. Read more about it here.
    • Maybe your assembly name for some reason does not match? If the custom code you want to use, you can omit the ;assembly=MyApp part of the namespace declaration and only specify the namespace.
    • For a quick test if it is a linker problem, turn linking off in the project settings.
Sign In or Register to comment.