Forum Xamarin.Forms

Linker Issue with Prism.Forms

JohnHanburyJohnHanbury USMember ✭✭

I have been trying for a while now to achieve linking in mainly my Xamarin.Forms Android project.
I'm using Prism in my project and when i set the Linker to SDK and User assemblies I seem to receive exceptions surround the Prism framework.
After a certain point of debugging my output spits back not info on what caused the app to crash meaning I cannot narrow down what assembly is causing the issue.
Has anyone had any success with linking and Prism

Best Answer

Answers

  • NMackayNMackay GBInsider, University mod
    edited June 2017

    Yes,

    Our Prism UWP/iOS & Android are currently released with SDK and User assemblies compiler settings with no issues with Prism.

    If your in debug mode then switch off the linker.

  • JohnHanburyJohnHanbury USMember ✭✭

    @NMackay did you guys have to exclude any of the prism dlls ?

  • NMackayNMackay GBInsider, University mod

    Your maybe hitting an issue loading a page using the navigation service, on the page push that's causing the issue see what the task returns than just awaiting it, that way you'll probably see the XAML exception (or whatever issue) that's causing the issue.

    var res = NavigationService.NavigateAsync(navigationPage, navParams,false);
    
  • JohnHanburyJohnHanbury USMember ✭✭

    I'll give it a try.
    Thanks for the help.
    Good to know it can be done

  • NMackayNMackay GBInsider, University mod

    @JohnHanbury

    Just come back to this thread if you need more help, there's also a really good Prism slack channel, it's a really helpful community.

  • JohnHanburyJohnHanbury USMember ✭✭

    Yes i'm in the slack group its great :smile:

    Thanks again @NMackay

  • JohnHanburyJohnHanbury USMember ✭✭
    edited June 2017

    @NMackay so i did a little test last night after the project still has issue building.
    I created a blank tester project using the template pack and then tried to create a full release build for that test project with linking and pro guard enabled.
    The project builds successfully and deploys to my device however the project fails to open.
    I think now this may be an environment issue as the tester project was untouched.

    For my android settings I have the following enabled:

    Bundle into Native Code: enabled
    Generate apk per ABI: enabled
    pro guard: enabled
    Java Heap: 1G
    Linker SDK and User Assemblies

    Tester Project is attached.
    Any ideas what I might be doing wrong?

  • NMackayNMackay GBInsider, University mod

    @JohnHanbury

    Hi, I had a look at your sample an can reproduce what your seeing, without enabling crash analytics in the app it's hard to say what's going on.

    I even signed and packages up an APK and manually installed on the device and the same thing occurs.

    I'd suggest using Hockeyapp's crash analytics to see what's causing the crash. After that I'd may ask via the slack channel or on Prism's github page as this is something I haven't encountered.

    I'd be interested to hear the outcome though, I'm finishing up in a day for annual leave so I'm busy trying to finish of a few things so I don't have time to research this issue.

    i can confirm I'm seeing the same issue though. Hockeyapp/mobile center crash analytics would be my 1st step though before asking for help so at least people have an idea of what's going on.

  • JohnHanburyJohnHanbury USMember ✭✭

    Totally agree, I'll set it up and test it out.
    I'll also reach out to the slack channel if the HockeyApp crash analytics does not uncover the issue.

  • grbarretogrbarreto BRMember ✭✭

    I'm facing the same issues related to prism.
    I've already try to add the usings in linkskip but i can't get through yet.
    If someone have a configuration that can share with us, i'll be glad.

  • grbarretogrbarreto BRMember ✭✭

    Running on debug I found that the issues has nothing to do with Prism, actually is Unity Container that throws the exception

  • RohanSatputeRohanSatpute USMember ✭✭
    edited December 2018

    @grbarreto
    Did you find what was going on and if you did, did you manage to work it out?

    @NMackay
    I am running into issue while link all assemblies is selected. I get following stack in release mode testing on device:

    [MonoDroid] UNHANDLED EXCEPTION:
    [MonoDroid] Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Prism.Unity.Extensions.DependencyServiceExtension", name = "(none)".
    [MonoDroid] Exception occurred while: while resolving.
    [MonoDroid] Exception is: InvalidOperationException - The type DependencyServiceExtension does not have an accessible constructor.
    [MonoDroid] -----------------------------------------------
    [MonoDroid] At the time of the exception, the container was:
    [MonoDroid]   Resolving Prism.Unity.Extensions.DependencyServiceExtension,(none)
    [MonoDroid]  ---> System.InvalidOperationException: The type DependencyServiceExtension does not have an accessible constructor.
    [MonoDroid]   at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForNullExistingObject (Microsoft.Practices.ObjectBuilder2.IBuilderContext context) [0x0003f] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,Microsoft.Practices.ObjectBuilder2.IBuilderContext)
    [MonoDroid]   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext+<>c__DisplayClass1.<GetBuildMethod>b__0 (Microsoft.Practices.ObjectBuilder2.IBuilderContext context) [0x00000] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp (Microsoft.Practices.ObjectBuilder2.IBuilderContext context) [0x00000] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp (Microsoft.Practices.ObjectBuilder2.IBuilderContext context) [0x00064] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp (Microsoft.Practices.ObjectBuilder2.IBuilderContext context) [0x0007c] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp (System.Type t, System.Object existing, System.String name, System.Collections.Generic.IEnumerable1[T] resolverOverrides) [0x00068] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]    --- End of inner exception stack trace ---
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp (System.Type t, System.Object existing, System.String name, System.Collections.Generic.IEnumerable1[T] resolverOverrides) [0x0007b] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp (System.Type t, System.String name, System.Collections.Generic.IEnumerable1[T] resolverOverrides) [0x00000] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainer.Resolve (System.Type t, System.String name, Microsoft.Practices.Unity.ResolverOverride[] resolverOverrides) [0x00000] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T] (Microsoft.Practices.Unity.IUnityContainer container, Microsoft.Practices.Unity.ResolverOverride[] overrides) [0x0000b] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Microsoft.Practices.Unity.UnityContainerExtensions.AddNewExtension[TExtension] (Microsoft.Practices.Unity.IUnityContainer container) [0x0000b] in <ba86a34b2f2c4964b8c588538e94514f>:0 
    [MonoDroid]   at Prism.Unity.PrismApplication.ConfigureContainer () [0x00006] in <87372f9b27174acda79905f75981148c>:0 
    [MonoDroid]   at Prism.PrismApplicationBase1[T].Initialize () [0x0002a] in <043d6108f97b47be9b936654ce1cdd35>:0 
    [MonoDroid]   at Prism.PrismApplicationBase1[T].InitializeInternal () [0x00006] in <043d6108f97b47be9b936654ce1cdd35>:0 
    [MonoDroid]   at Prism.PrismApplicationBase1[T]..ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in <043d6108f97b47be9b936654ce1cdd35>:0 
    [MonoDroid]   at Prism.Unity.PrismApplication..ctor (Prism.Unity.IPlatformInitializer initializer) [0x00000] in <87372f9b27174acda79905f75981148c>:0 
    [MonoDroid]   at Xcelerator.App..ctor (Prism.Unity.IPlatformInitializer initializer) [0x00000] in <a063f185c956423d9f7b77d1e6931080>:0 
    [MonoDroid]   at Xcelerator.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x000d5] in <04f8711ea9dc4a7aa994887de3f15066>:0 
    [MonoDroid]   at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x0000f] in <510f2bbeb26847d899a5c97b011ee9a4>:0 
    [MonoDroid]   at (wrapper dynamic-method) System.Object:69f0ac87-fe43-4e71-85ae-2715564b2a6b (intptr,intptr,intptr)
    
  • RohanSatputeRohanSatpute USMember ✭✭

    I added the following linkskips :

    --linkskip=Microsoft.Practices.Unity --linkskip=Prism --linkskip=Prism.Unity.Forms --linkskip=Prism.Forms --linkskip=Microsoft.Practices.ServiceLocation

    Now I am also getting the same error with ArrayResolutionStrategy like @grbarreto.
    https://forums.xamarin.com/discussion/102641/prism-unity-container-link-sdk-and-user-assemblies

  • LyndonHugheyLyndonHughey USUniversity ✭✭✭

    I'm also having problems linking all assemblies in a prism project.
    I was running into the "Microsoft.Practices.Unity.ResolutionFailedException" and skipped linking on the Microsoft.Practices.Unity dll. That issue went away.

    I'm now having problems with "Prism.Unity.Extensions.DependencyServiceExtension". I've linked the Prism.Unity.Forms.dll, which contains the Prism.Unity.Extensions namespace, but no soup. This project is using Prism. 6.3x.

  • FinitelyFailedFinitelyFailed SEMember ✭✭

    @LyndonHughey I have the same problem.

  • JohnHanburyJohnHanbury USMember ✭✭

    I believe @grbarreto is correct that it is a Unity issue not a Prism issue. I no longer use Unity for my DI Container instead I use DryIoc so I will test the linker out again and report the results when I get a chance.

  • grbarretogrbarreto BRMember ✭✭

    @RohanSatpute, @LyndonHughey, @FinitelyFailed
    See the link that @BrianLagunas posted above.

  • BoHansenBoHansen DKMember ✭✭
    edited December 2017

    Hi, I seem to have ran into this problem. With no heads up. All the sudden this issues appeared after an update to 8.1 I think. This is very bad. It worked in debug. It does not in release. I get:

    [MonoDroid] UNHANDLED EXCEPTION:
    [MonoDroid] Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "System.Object", name = "ProfilePage".
    [MonoDroid] Exception occurred while: Calling constructor Client.ProfilePage().
    [MonoDroid] Exception is: InvalidCastException - Specified cast is not valid.
    [MonoDroid] -----------------------------------------------
    [MonoDroid] At the time of the exception, the container was:
    [MonoDroid]
    [MonoDroid] Resolving Client.ProfilePage,ProfilePage (mapped from System.Object, ProfilePage)
    [MonoDroid] Calling constructor Client.ProfilePage()
    [MonoDroid] ---> System.InvalidCastException: Specified cast is not valid.
    [MonoDroid] at Client.ProfilePage.InitializeComponent () [0x004ab] in <88727d723b254ae5af1957047fc34de1>:0

    • 1 Question
      Is there a way to revert to the previous installation where this actually worked?

    • 2 Why did this issue appear all the sudden? I've never had this issue. And problem is that nothing works and none of the above suggestions seems to have any effect.

    • 3 Is this seems to be a linker issue (where the compiler strips some important stuff...?), how to fix it. I'm on VS for mac.

    • 4 I have tried to apply the "--linkskip=Microsoft.Practices.Unity --linkskip=Prism --linkskip=Prism.Unity.Forms --linkskip=Prism.Forms --linkskip=Microsoft.Practices.ServiceLocation" suggestion under Android Build -> Advanced -> Java arguments. That made the compiler stop working I think. It could not compile.

    • 5 It seems to be an issue with the xaml-auto generated stuff. How to "preserve" this? Would I be needing a xml-file (that was Brians link I think.). How would I apply that with VS for Mac. I can see anywhere I can do a "Build Action" with LinkerDescription.

    • UPDATE: Sorry for nr 5. I did not read the answer correct. I will be trying this https://developer.xamarin.com/guides/cross-platform/advanced/custom_linking/. I hope it will work.

    • 6 I have tried entering the assembly names manually - that did not work.

    Sorry for the many questions. I have tried many things.

    Any help would be nice.

    Thanks

  • BoHansenBoHansen DKMember ✭✭

    UPDATE Hi all. I have fixed the issue my self. It appears that a compiler setting : [XamlCompilation (XamlCompilationOptions.Compile)] - that should optimize the performance. But it killed the app during runtime. It would start with a spalshscreen. But the app would die trying to resolve the xaml.

    Sorry to have waisted your time (If anybody gave this a though). I do NOT have this issue. I looked like the issue described. But it's not. I would have deleted my post -but apparently I can not do that. Just so nobody got confused while reading my post.

    I ended up removing "[XamlCompilation (XamlCompilationOptions.Compile)]" and the app came back to life. I did not use the Linker-stuff. All though I got a lot smarter regarding this. Now I know how that is done.

    Also I updated the Unity to the newest.

    Prism ROCKS!

  • Hey guys

    I'm in the process of exploring Prism to develop some Xamarin Forms Applications.

    I used the template extension to scaffold the new project, with DryIoc.
    It is using the Prism pre-release version (7.0.0.168-pre).
    I created a new view (LoginView), with absolutely no controls inside whatsoever.

    If i try to deploy the newly created app to android, without linker enabled, or with the linker set to sdk, it deploys and runs just fine.

    If i try to deploy with the linker set to all, it fails with the error:
    System.TypeInitializationException: The type initializer for 'Registry' threw an exception. ---> System.TypeInitializationException: The type initializer for 'DryIoc.WrappersSupport' threw an exception. ---> DryIoc.ContainerException: Argument of type MethodInfo is null. 12-15 13:59:56.977 I/MonoDroid(17130): at DryIoc.Throw.ThrowIfNull[T] (T arg, System.Int32 error, System.Object arg0, System.Object arg1, System.Object arg2, System.Object arg3) [0x0002b] in <e3b94bea7996441fb08b4feabdd2e9d9>:0 12-15 13:59:56.977 I/MonoDroid(17130): at DryIoc.WrappersSupport..cctor () [0x0013e] in <e3b94bea7996441fb08b4feabdd2e9d9>:0 12-15 13:59:56.977 I/MonoDroid(17130): --- End of inner exception stack trace --- 12-15 13:59:56.977 I/MonoDroid(17130): --- End of inner exception stack trace --- 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.DryIoc.PrismApplication.CreateContainer () [0x00006] in <f391f9c2cac64683a56d0cb59825014a>:0 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T].Initialize () [0x0001e] in :0 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T].InitializeInternal () [0x00006] in <feb5c9b233df462bb483ff4dd8463238>:0 12-15 13:59:56.978 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T]..ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in <feb5c9b233df462bb483ff4dd8463238>:0 12-15 13:59:56.978 I/MonoDroid(17130): at Prism.DryIoc.PrismApplication.set_ModuleCatalog (Prism.Modularity.IModuleCatalog value) [0x00000] in <f391f9c2cac64683a56d0cb59825014a>:0 12-15 13:59:56.978 I/MonoDroid(17130): at CABuffet.App..ctor (Prism.DryIoc.IPlatformInitializer initializer) [0x00000] in C:\Projects\CABuffet\CABuffet\CABuffet\App.xaml.cs:18 12-15 13:59:56.978 I/MonoDroid(17130): at CABuffet.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00027] in C:\Projects\CABuffet\CABuffet\CABuffet.Android\MainActivity.cs:20

    I have created my own LinkerDescription file to preserve the members, yet i have little experience with linker.

      <assembly fullname="Prism.Forms">
        <type fullname="Prism.Common.ApplicationProvider" preserve="all" />
        <type fullname="Prism.Services.PageDialogService" preserve="all" />
        <type fullname="Prism.Services.DeviceService" preserve="all" />
      </assembly>
    
      <assembly fullname="Prism.DryIoc.Forms" >
        <namespace fullname="Prism.DryIoc" preserve="all" />
      </assembly>
      <assembly fullname="Prism">
        <namespace fullname="Prism.Ioc" preserve="all" />
      </assembly>
      <assembly fullname="netstandard">
        <namespace fullname="System.Reflection" preserve="all" />
      </assembly>
    </linker>
    

    Can anyone point me into the right direction?

    Package info

    Platform: Xamarin Forms
    Prism version: 7.0.0.168-pre
    Xamarin version (if applicable): Xamarin Android 8.1.0.25
    Other version info: .NetStandard v2.0

    Repro steps

    1. Use the Prism Project Template to create a new Prism Application
    2. Select DryIoc as your container
    3. Create a new View and ViewModel using the Prism Item Template
    4. Set Android Linker Settings to All
    5. Deploy to a simulator
  • Hey guys

    I'm in the process of exploring Prism to develop some Xamarin Forms Applications.

    I used the template extension to scaffold the new project, with DryIoc.
    It is using the Prism pre-release version (7.0.0.168-pre).
    I created a new view (LoginView), with absolutely no controls inside whatsoever.

    If i try to deploy the newly created app to android, without linker enabled, or with the linker set to sdk, it deploys and runs just fine.

    If i try to deploy with the linker set to all, it fails with the error:
    System.TypeInitializationException: The type initializer for 'Registry' threw an exception. ---> System.TypeInitializationException: The type initializer for 'DryIoc.WrappersSupport' threw an exception. ---> DryIoc.ContainerException: Argument of type MethodInfo is null. 12-15 13:59:56.977 I/MonoDroid(17130): at DryIoc.Throw.ThrowIfNull[T] (T arg, System.Int32 error, System.Object arg0, System.Object arg1, System.Object arg2, System.Object arg3) [0x0002b] in <e3b94bea7996441fb08b4feabdd2e9d9>:0 12-15 13:59:56.977 I/MonoDroid(17130): at DryIoc.WrappersSupport..cctor () [0x0013e] in <e3b94bea7996441fb08b4feabdd2e9d9>:0 12-15 13:59:56.977 I/MonoDroid(17130): --- End of inner exception stack trace --- 12-15 13:59:56.977 I/MonoDroid(17130): --- End of inner exception stack trace --- 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.DryIoc.PrismApplication.CreateContainer () [0x00006] in <f391f9c2cac64683a56d0cb59825014a>:0 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T].Initialize () [0x0001e] in :0 12-15 13:59:56.977 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T].InitializeInternal () [0x00006] in <feb5c9b233df462bb483ff4dd8463238>:0 12-15 13:59:56.978 I/MonoDroid(17130): at Prism.PrismApplicationBase1[T]..ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in <feb5c9b233df462bb483ff4dd8463238>:0 12-15 13:59:56.978 I/MonoDroid(17130): at Prism.DryIoc.PrismApplication.set_ModuleCatalog (Prism.Modularity.IModuleCatalog value) [0x00000] in <f391f9c2cac64683a56d0cb59825014a>:0 12-15 13:59:56.978 I/MonoDroid(17130): at CABuffet.App..ctor (Prism.DryIoc.IPlatformInitializer initializer) [0x00000] in C:\Projects\CABuffet\CABuffet\CABuffet\App.xaml.cs:18 12-15 13:59:56.978 I/MonoDroid(17130): at CABuffet.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00027] in C:\Projects\CABuffet\CABuffet\CABuffet.Android\MainActivity.cs:20

    I have created my own LinkerDescription file to preserve the members, yet i have little experience with linker.

      <assembly fullname="Prism.Forms">
        <type fullname="Prism.Common.ApplicationProvider" preserve="all" />
        <type fullname="Prism.Services.PageDialogService" preserve="all" />
        <type fullname="Prism.Services.DeviceService" preserve="all" />
      </assembly>
    
      <assembly fullname="Prism.DryIoc.Forms" >
        <namespace fullname="Prism.DryIoc" preserve="all" />
      </assembly>
      <assembly fullname="Prism">
        <namespace fullname="Prism.Ioc" preserve="all" />
      </assembly>
      <assembly fullname="netstandard">
        <namespace fullname="System.Reflection" preserve="all" />
      </assembly>
    </linker>
    

    Can anyone point me into the right direction?

    Package info

    Platform: Xamarin Forms
    Prism version: 7.0.0.168-pre
    Xamarin version (if applicable): Xamarin Android 8.1.0.25
    Other version info: .NetStandard v2.0

    Repro steps

    1. Use the Prism Project Template to create a new Prism Application
    2. Select DryIoc as your container
    3. Create a new View and ViewModel using the Prism Item Template
    4. Set Android Linker Settings to All
    5. Deploy to a simulator
  • BozhiQianBozhiQian AUUniversity ✭✭
    edited February 2018

    I have the same issue as above.
    These are my steps:

    1. Use the Prism Project Template to create a new Prism Application
    2. Select Unity as your container
    3. On the Android project property window, Select "Android Options", and set Linking dropdown list to "SDK and User Assemblies".
    4. Run debug to deploy to Visual Studio Emulator for Android.

    Before step3, I can run it on Visual Studio Emulator for Android.
    But after step 3, it has issue at running reported from VS2017 output window though building is always successful.

    Resolution of the dependency failed, type = 'Prism.Modularity.IModuleCatalog', name = '(none)'.
    Exception occurred while: while resolving.
    Exception is: ArgumentNullException - Value cannot be null.
    Parameter name: method
    -----------------------------------------------
    At the time of the exception, the container was: 
      Resolving Prism.Modularity.ModuleCatalog,(none) (mapped from Prism.Modularity.IModuleCatalog, (none))
        Resolving Prism.Modularity.ModuleCatalog,(none)
    

    And I tried to add a linker.xml to Android project.

    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
    
      <assembly fullname="Prism.Forms">
        <type fullname="Prism.Modularity.IModuleCatalog" preserve="fields">
          <method name=".ctor" />
        </type>
      </assembly>
    </linker>
    

    But it did not work at all.

    The reason that I need to do step 3 is resolving issue later on once installed "Microsoft.EntityFrameworkCore.Sqlite" nuget package that will result another famous issue "Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration."

    And because of the step 3 issue, I am not able to do any futher work.
    I tried use Autofac at step 2, but it has the same issue.

    Please give help!!! Thanks.

    Sorry guys, I move this to another post as this has been marked as answered.
    https://forums.xamarin.com/discussion/comment/308785

  • JosueSamanoJosueSamano USMember ✭✭

    @JohnHanbury said:
    @NMackay so i did a little test last night after the project still has issue building.
    I created a blank tester project using the template pack and then tried to create a full release build for that test project with linking and pro guard enabled.
    The project builds successfully and deploys to my device however the project fails to open.
    I think now this may be an environment issue as the tester project was untouched.

    For my android settings I have the following enabled:

    Bundle into Native Code: enabled
    Generate apk per ABI: enabled
    pro guard: enabled
    Java Heap: 1G
    Linker SDK and User Assemblies

    Tester Project is attached.
    Any ideas what I might be doing wrong?

    If you had done the deploy to generate the apk, first delete the contents of bin and obj folders and then run the project again

  • DougMaurerDougMaurer USMember ✭✭

    Boy oh boy ... this is getting frustrating. I have upgraded all the Xamarin and Prism libraries and I think I am now regretting it. After taking a couple of weeks to rebuild my Xamarin Forms project from scratch, I can get it to run in debug mode on my connected Samsung S6 just fine. But, when I try to run in Release mode, I am now getting all the same issues posted here.

    I have created the linker.xml file. I have commented out the microsoft.unity.... references because of newer Prism, etc,. I am getting errors in the device log pertaining to errors in my constructors that use Unity. I don't even know what to ask any more after reading this post.

    What can I post to ask the correct question?

  • ossentooossentoo GBMember ✭✭
    edited May 2018

    Hi Doug,

    Did you ever resolve this problem?

  • JoeDluzenJoeDluzen USBeta ✭✭

    Hi all, I'm currently stuck on this as well, specifically the IModuleCatalog. I've tried multiple variations of the suggestions listed above.

  • JoeDluzenJoeDluzen USBeta ✭✭

    Managed to link by skipping:

    • Prism
    • Prism.Forms
    • Unity.Abstractions
    • Unity.Container

    Linking any one of these caused it to fail at runtime.

  • Thanks @JoeDluzen ! I' used your answer and it works!

    I'm using Prism 7 and Unity

    My linker.xml file:

    <linker>
        <assembly fullname="Prism.Forms">
            <type fullname="Prism.Common.ApplicationProvider" preserve="all" />
            <type fullname="Prism.Services.PageDialogService" preserve="all" />
            <type fullname="Prism.Services.DeviceService" preserve="all" />
            <type fullname="Prism.Ioc*" preserve="all" />
            <type fullname="Prism.Modularity*" preserve="all" />
            <type fullname="Prism.Navigation*" preserve="all" />
            <type fullname="Prism.Behaviors.PageBehaviorFactory" preserve="all">
                <method name=".ctor" />
            </type>
            <type fullname="Prism.Services.DependencyService" preserve="all">
                <method name=".ctor" />
            </type>
        </assembly>
    
        <assembly fullname="Prism">
            <type fullname="Prism.Navigation*" preserve="all" />
            <type fullname="Prism.Logging.EmptyLogger" preserve="all">
                <method name=".ctor" />
            </type>
        </assembly>
    
        <assembly fullname="Unity.Abstractions">
            <type fullname="*" />
        </assembly>
    
        <assembly fullname="Unity.Container">
            <type fullname="*" />
        </assembly>
    
        <assembly fullname="Newtonsoft.Json">
            <type fullname="Newtonsoft.Json.*" preserve="all" />
        </assembly>
    
    </linker>
    
  • stemadostemado Member ✭✭✭

    @NMackay said:
    Yes,

    Our Prism UWP/iOS & Android are currently released with SDK and User assemblies compiler settings with no issues with Prism.

    If your in debug mode then switch off the linker.

    Your answer saved me once again. Thank you, thank you, thank you.

  • PetiPeti Member ✭✭

    @RobsonAmorim said:
    Thanks @JoeDluzen ! I' used your answer and it works!

    I'm using Prism 7 and Unity

    My linker.xml file:

    <linker>
        <assembly fullname="Prism.Forms">
            <type fullname="Prism.Common.ApplicationProvider" preserve="all" />
            <type fullname="Prism.Services.PageDialogService" preserve="all" />
            <type fullname="Prism.Services.DeviceService" preserve="all" />
            <type fullname="Prism.Ioc*" preserve="all" />
            <type fullname="Prism.Modularity*" preserve="all" />
            <type fullname="Prism.Navigation*" preserve="all" />
            <type fullname="Prism.Behaviors.PageBehaviorFactory" preserve="all">
                <method name=".ctor" />
            </type>
            <type fullname="Prism.Services.DependencyService" preserve="all">
                <method name=".ctor" />
            </type>
        </assembly>
    
        <assembly fullname="Prism">
            <type fullname="Prism.Navigation*" preserve="all" />
            <type fullname="Prism.Logging.EmptyLogger" preserve="all">
                <method name=".ctor" />
            </type>
        </assembly>
    
        <assembly fullname="Unity.Abstractions">
            <type fullname="*" />
        </assembly>
    
        <assembly fullname="Unity.Container">
            <type fullname="*" />
        </assembly>
    
        <assembly fullname="Newtonsoft.Json">
            <type fullname="Newtonsoft.Json.*" preserve="all" />
        </assembly>
    
    </linker>
    

    Great example, this did the trick for me too.

  • AMAXAMAX USMember ✭✭

    @JohnHanbury said:
    I believe @grbarreto is correct that it is a Unity issue not a Prism issue. I no longer use Unity for my DI Container instead I use DryIoc so I will test the linker out again and report the results when I get a chance.

    even I used DryIoc, I'm still getting the same error. Can you share your LinkDescription XAML?

  • kefkef Member ✭✭

    @NMackay said:

    Hello I am getting this error when i set linking to sdk and user both and when i set to only sdk then there are no error.

    Unhandled Exception:

    Unity.Exceptions.ResolutionFailedException: Resolution of the dependency failed, type = 'Prism.Modularity.IModuleCatalog', name = '(none)'.
    Exception occurred while: while resolving.
    Exception is: ArgumentNullException - Value cannot be null.

    Parameter name: method

    At the time of the exception, the container was:
    Resolving Prism.Modularity.ModuleCatalog,(none) (mapped from Prism.Modularity.IModuleCatalog, (none))
    Resolving Prism.Modularity.ModuleCatalog,(none)
    occurred

  • NMackayNMackay GBInsider, University mod

    @kef said:

    @NMackay said:

    Hello I am getting this error when i set linking to sdk and user both and when i set to only sdk then there are no error.

    Unhandled Exception:

    Unity.Exceptions.ResolutionFailedException: Resolution of the dependency failed, type = 'Prism.Modularity.IModuleCatalog', name = '(none)'.
    Exception occurred while: while resolving.
    Exception is: ArgumentNullException - Value cannot be null.

    Parameter name: method

    At the time of the exception, the container was:
    Resolving Prism.Modularity.ModuleCatalog,(none) (mapped from Prism.Modularity.IModuleCatalog, (none))
    Resolving Prism.Modularity.ModuleCatalog,(none)
    occurred

    I haven't used Unity for ages but so not sure I can help much. You could add explicit Preserve attributes to make sure it can't be linked out.

    [assembly: Preserve(typeof(Prism.Modularity.ModuleManager), AllMembers = true)]
    
    

    I would recommend looking at the post above for Unity or asking on the Prism slack channel.

  • kefkef Member ✭✭

    I am using xamarin prism

  • NMackayNMackay GBInsider, University mod

    @kef said:
    I am using xamarin prism

    My original answer was June 2017, a lot has changed since then. you'll have to experiment to stop assemblies been linked out until you get something that works for you. My suggestion is to ensure specific assemblies don't get out, either via command line compilation arguments, a linker file or assembly attributes. Not sure what else to say.

  • kefkef Member ✭✭

    How to know which assembly not worked?

  • NMackayNMackay GBInsider, University mod

    Try deploying the app to your device in debug with "Sdk and Assembly linking" enabled, shoudl help you narrow down what is doing on.

    I my case last time, Xamarin Essentials was been linked out despite been linked safe.

Sign In or Register to comment.