Forum Xamarin Cross Platform with Xamarin

MVVMCross FAQ's - need some more clarification

LeelaPrasannaKumarLeelaPrasannaKumar USUniversity
edited October 2013 in Cross Platform with Xamarin

Read on the blogs

  1. Create an iOS solution in VS2012

  2. Add any other UI project you wish to support.

  3. Grab MvvmCross in NuGet for all of these projects.

Add a new project with type Portable Class Library (PCL).
This will be your core library which is shared between all UIs.

Here I was confused about the PCL part .. People say PCL project will be the core that would be used by all the UI's ??

I have a set of Viewmodels which use the Data Access Layer, Business logic, Models ( Currently these are not PCL libraries and they are class libraries build based on the project type for IOS and android)
Now each of my Data Access layer, Business Logic, Models sit as separate dll's -- type is class libraries

Most importantly all my dll's are making use of references that are not available when I try to create a PCL core library

Question 1:
1. Can the PCL Core project(that is used across UI's) can refer to these libraries ???? I mean in IOS it would refer to IOS version of dll's, in android it would refer to android version of the dll's ( sorry for being naive)
I couldn't compile the PCL Core by linking my models, business logic, DAL files inside the PCL core project ( as the references for these are not available in PCL project type)

I wasn't even able to find the basic modules listed here : like System.SerivceModel in the PCL project
Do we need to install anything extra there?

I wasn't able to compile because DllImport keyword is missing. This comes from MScorelib.dll
Also System.Threading.Tasks; is missing

My .NET portable subset library path : **C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile104**
When I create a PCL based project above is the default reference that gets added

Question 2:
2. All the viewModels would be part of the PCL Core mvvmcross project ? Atleast I could understand this part from the examples


  • DerekBeattie.6675DerekBeattie.6675 US ✭✭
    edited October 2013

    "Can the PCL Core project(that is used across UI's) can refer to these libraries ????"

    PCL's can only reference other PCL's, I believe but there are tricks to reference a PCL "shim" that ends up being the implementation. This article talks about that.

    Having said that, with MvvmCross if you have code that can't live in a portable or code that depends on platform specific libs you can use the plugins. So the interface lives in the portable and the platform specific bits live in their own projets. I should say that not only the interface but any code that is part of the plugin that can live in the portable project should. Try and abstract out the platform specific parts into their own projects.

  • LeelaPrasannaKumarLeelaPrasannaKumar USUniversity

    Hi Derek

    thanks for the inputs

    But I was unable to compile basic items when creating a Portable Class library in visual studio

    References like System.SerivceModel, Dllimport keyword in MSCOrelib.dll, System.Threading.Tasks are not found

    In the PCL project the .NET portable subset library path : C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile104

    Is this the right path?

Sign In or Register to comment.