IUnityContainer for Xamarin.Mac

Just went through the hassle to use Prism Unity IoC for iOS and Android. Trying to apply that to our Xamarin.Mac app which shares the "CORE" business logic. I am unable to add Prism or Prism for Forms to the Packages.

Is there another way to get the IUnityContainer for Xamarin.Mac. Our "CORE" uses this and it would suck to ifdef with autofac.

Answers

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    What libraries a given Xamarin.Mac application can used is fundamentally based on the target framework of your application:

    https://developer.xamarin.com/guides/mac/advanced_topics/target-framework/

    In many cases, nuget and 3rd party applications support the "normal" desktop XM 4.5 target framework before/more often than the "mobile" one that is similar to iOS (which would require a special build).

  • MusicnotesDevMusicnotesDev USMember ✭✭

    Came up with a new plan. To get things to build with our CORE, in the OSX project I created a stub class with namespace "Microsoft.Practices.Unity" and a class for "Prism.Unity".

    In Microsoft.Practices.Unity I have a similar IUnityContainer interface which I implement with Autofac.

    In "Prism.Unity" I just have "IPlatformInitializer".

    Under the hood it's Autofac but to the reset of the code it's Unity :smile:

  • MusicnotesDevMusicnotesDev USMember ✭✭

    Got it to build and launch when switching to .NET 4.5. But it always crashes with insights.

    I tried to revert to the Xamarin Mobile Framework and it wont install insights anymore. Not even sure how we got it to install.

    at <0xffffffff>
    at (wrapper managed-to-native) System.Windows.Forms.XplatUICarbon.CGDisplayBounds (intptr)
    at System.Windows.Forms.XplatUICarbon.get_WorkingArea () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs:2263
    at System.Windows.Forms.XplatUICarbon.get_VirtualScreen () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs:2257
    at System.Windows.Forms.XplatUI.get_VirtualScreen () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUI.cs:420
    at System.Windows.Forms.Screen..cctor () [0x00041] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/Screen.cs:53
    at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr)
    at <0xffffffff>
    at Xamarin.InsightsCore.PlatformServices.GetDeviceInfoData ()
    at Xamarin.InsightsCore.MessageProcessor.SubmitDeviceInfo ()
    at Xamarin.InsightsCore.Core.b__19_1 (System.Threading.Tasks.Task)
    at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:63
    at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
    at System.Threading.Tasks.Task.ExecutionContextCallback (object) [0x00007] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2865
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x0008d] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task&) [0x0005f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2827
    at System.Threading.Tasks.Task.ExecuteEntry (bool) [0x0006f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2760
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2707
    at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:854
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00030] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1209
    at (wrapper runtime-invoke) .runtime_invoke_bool (object,intptr,intptr,intptr)

  • MusicnotesDevMusicnotesDev USMember ✭✭

    Got it to build and launch when switching to .NET 4.5. But it always crashes with insights.

    I tried to revert to the Xamarin Mobile Framework and it wont install insights anymore. Not even sure how we got it to install.

    at <0xffffffff>
    at (wrapper managed-to-native) System.Windows.Forms.XplatUICarbon.CGDisplayBounds (intptr)
    at System.Windows.Forms.XplatUICarbon.get_WorkingArea () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs:2263
    at System.Windows.Forms.XplatUICarbon.get_VirtualScreen () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs:2257
    at System.Windows.Forms.XplatUI.get_VirtualScreen () [0x00000] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUI.cs:420
    at System.Windows.Forms.Screen..cctor () [0x00041] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Windows.Forms/System.Windows.Forms/Screen.cs:53
    at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr)
    at <0xffffffff>
    at Xamarin.InsightsCore.PlatformServices.GetDeviceInfoData ()
    at Xamarin.InsightsCore.MessageProcessor.SubmitDeviceInfo ()
    at Xamarin.InsightsCore.Core.b__19_1 (System.Threading.Tasks.Task)
    at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00027] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:63
    at System.Threading.Tasks.Task.Execute () [0x00016] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
    at System.Threading.Tasks.Task.ExecutionContextCallback (object) [0x00007] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2865
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x0008d] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
    at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task&) [0x0005f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2827
    at System.Threading.Tasks.Task.ExecuteEntry (bool) [0x0006f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2760
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2707
    at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:854
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00030] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.10.0.113/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1209
    at (wrapper runtime-invoke) .runtime_invoke_bool (object,intptr,intptr,intptr)

Sign In or Register to comment.