Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVVM Cross support for Xamarin Studio on a Mac

I have been exploring the use of MVVM Cross on Xamarin Studio on a Mac. I've been going through the tutorials for N+1 days of MvvmCross on YouTube and I've run into a roadblock that hopefully someone else has experienced.

The tutorials use PCLs and VS 2012, but since I'm on a Mac, I have to use Xamarin Studio. I understand PCLs are not support in Xamarin Studio so I've created a base C# project and then linked the libraries to a Xamarin.Android project. I've read quite a few MvvmCross posts including this one but haven't been able to find a solution.

The project builds successfully and appears to deploy to the emulator successfully, but I can not get the app to run on the emulator. The app immediately closes and the only error I receive is the following non-descript message in the Application Output of Xamarin Studio.

[monodroid-gc] GREF GC Threshold: 1800
[mono] Stacktrace:
[mono] 
[mono] 
[mono] Unhandled Exception:
[mono] System.NullReferenceException: Object reference not set to an instance of an object
[mono] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object

I've set multiple breakpoints but cannot get any them to fire, it appears the error is occurring before my code is run. I downloaded the sample code for the project and it ran successfully so I then went line by line to check for errors but with no success (I even replaced my class files with those from the example. I've confirmed that all of the DLLs are correct. I'm using the precompiled libraries from https://github.com/slodge/MvvmCross-Binaries.

I'm really not sure where to go next to determine the cause of this error. Has anyone else experienced this? I know both Xamarin and MvvmCross focus on Visual Studio integration and PC development; is MvvmCross stable enough to use on Xamarin Studio for a Mac? Does anyone know what my error may be, or what to try next?

I know this is a fairly undefined problem but I'm hoping I'm not the only one to experience this. I've tried to be a descriptive as possible but if anyone need more information, please let me know. Thanks.

like image 507
Matthew Avatar asked May 23 '13 00:05

Matthew


2 Answers

Has anyone else experienced this?

No-one I've seen.

I know both Xamarin and MvvmCross focus on Visual Studio integration and PC development

This definitely isn't true for Xamarin - in fact (in my opinion) the reverse is true - I think they work 'Xamarin Studio on a Mac' first, with Visual Studio support second.

For MvvmCross, I generally do work Visual Studio first - this is mainly because I need to use Windows project types (Wpf, WindowsPhone, WindowsStore), because I prefer to use PCLs, and because Resharper owns my coding soul.

is MvvmCross stable enough to use on Xamarin Studio for a Mac?

This is too subjective a question for me to answer. I can tell you lots of Mac-people do use it... and that no-one who has tried has then turned around to me and told me that MvvmCross wasn't stable enough.

The situation with Xamarin PCL support is evolving - the current support seems to change a little with every release currently, and there is a big PCL release coming at some point very soon. This is scheduled for any day now - so I definitely cannot claim that the PCL situation is currently stable.

NuGet2.5 support is also changing - see https://github.com/mrward/monodevelop-nuget-addin/issues/13 - I have no idea when this will be fully available or will know about PCLs on the Mac, but at least the effort has started.

Note: If you want to, then you can always work with Xamarin project types and with file linking instead of with PCL project types. Just because MvvmCross uses PCLs internally it doesn't mean you have to.

Does anyone know what my error may be

I've no idea what your error is there - that NullReferenceException isn't the most verbose error :( You might be able to get more trace from logcat? Other than that, Xamarin forums or support might be able to assist.

what to try next?

I've recorded today's N+1 purely on the Mac without Nuget.

This is currently uploading to:

  • http://slodge.blogspot.co.uk/2013/05/n22-from-basics-on-mac-n1-days-of.html
  • http://youtu.be/UC2r4mmj3UI

This is a 'warts and all' live demo of me developing a first Android and iOS project using MvvmCross and PCLs on the Mac. Clearly you can see some issues with things like Xamarin Studio intellisense and with Android emulator debugging (note that these debugger/emulator issues are independent of MvvmCross and PCLs!)

I believe this also shows that right now today on the Mac, Xamarin.iOS is much more mvvmcross/pcl friendly than xamarin.android - but that both are possible to use.

Note that for this demo, I use the assemblies from the VS folder in https://github.com/slodge/mvvmCross-binaries/

like image 113
Stuart Avatar answered Oct 21 '22 23:10

Stuart


I have been same problem.

I have solved migrating my code solution to another new project. There was no problem with PCL and project link assembly.

I don't know why my solution was broken. I suspect something about package namespace that must be consistent in .xaml and project option.

like image 45
Luigi Saggese Avatar answered Oct 21 '22 23:10

Luigi Saggese