MVVM Store App with Portable Class Library - mvvm-light

I created a Portable Class Library and added the MVVM Light PCL to it.
PCL
--Model
----Term.cs
Term.cs contains a reference to GalaSoft.MvvmLight.
I also created a MVVM Store C# Application. I added a reference to the PCL above. However, when I build the project, I get the following errors:
Cannot resolve Assembly or Windows Metadata file 'GalaSoft.MvvmLight.dll'
Type universe cannot resolve assembly: GalaSoft.MvvmLight, Version=4.0.23.23876, Culture=neutral, PublicKeyToken=null
If I remove the model class (Term.cs), the MVVM C# Application builds successfully?
I will appreciate any assistance in resolving this.

Couple of things to check up front -- are you using NuGet >= 2.1? 2.2 was just released yesterday.
Are you using the Portable.MVVMLightLibs package from NuGet?
Do you have a reference to the Portable.MVVMLightLibs in your store app project? If you're deriving from ViewModelBase, then other projects that use it need a reference to the libraries that contain base types. That's regular .NET and has nothing to do with PCLs. If you add the package to your store app, does that resolve the issue?
Regards,
Oren

Related

Entity Framework Code First Approach to Xamarin.Forms PCL app

Can I have a .NET Class Library project with Entity Framework 6.1.1 (in windowsazure.mobileservices.backend.entity nuget package) work with Xamarin.Forms PCL app? Is this achievable? If not what are the possible complications?
Question Background:
I am working on a Xamarin.Forms cross platform PCL app with Azure Mobile Services back-end, targeting Android, iOS, Windows 8.1 and WinPhone 8.1. I actually dont care about Windows 8.1 but Visual Studio does not allow me to remove this target. So it stays.
Azure Mobile Services is setup, but I need the tables to be generated automatically (strongly avoiding manually typing table definitions in azure portal). I decided to go EF code first way with windowsazure.mobileservices.backend.entity nuget package to achieve this. However, the Xamarin.Forms PCL project does not support additional assemblies.
I am thinking of adding this package into a separate class library project and referring to it from the PCL project.
Thanks for your help!
The EntityData type is the required superclass of DTOs on the server SDK. Unfortunately, it has dependencies that are not supported in a PCL project, so it has to be used with a full .NET 4.5 project.
You could instead use partial classes to share DTOs between client and server. Just put all of the non system property types in a common code file that's shared between client and server. Then, on the client, add the system property implementation (ID field, UpdatedAt optionally, Version optionally). On the server, add another partial class definition that inherits from EntityData.

Why is my project failing to reference the System.ComponentModel assembly?

My project is set to .NET Framework 4.5. I get the following error when attemping to use SimpleIOC (from MVVM Light) in my WPF project:
Error 3 Reference required to assembly 'System.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the implemented interface 'System.IServiceProvider'. Add one to your project.
I can't figure out why it's giving me this error. From what I understand, this is a mscorlib class so I'm not sure where it is getting System.ComponentModel from.
I can write Dim test As IServiceProvider without the compiler complainging. Is there some kind of version issue?
It seems like a possible Visual Studio bug. I created a new WPF project and was able to find the System.ComponentModel.dll in the list of .Net Framework assemblies. For my current project, I ended up browsing to it to add a reference to it. All is well now.

how to start working on xamarin with signalr

I'm new to both Xamarin and SignalR. While I'm able to easily follow the tutorials for SignalR on Visual Studio, and get a sample chat application working, I'm not able to make it work on Xamarin. I tried to reference the signalr assemblies in Xamarin, but it fails with the following error -
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Security, Version=4.0.0.0, Culture=neutral
But I'm not able to find System.Security to add to references.
Am I doing this right?
I also tried looking for SignalR in Components. But couldn't find it.
Also, I tried to find some tutorials on SignalR in Xamarin that would guide me through this process. But I wasn't able to find any. Can someone point me to some blogs/tutorials that can help me setup SignalR in Xamarin?
Thanks!
These steps worked for me:
Installed the beta updates on Xamarin
Got the dev branch on signalr and built it to include mono support
Removed reference to signalr.core assembly (this was the one referencing system.security)
If you are on Xamarin.Forms Net standard
(https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/), just install nuget 'Microsoft.AspNet.SignalR.Client' and use all sample code provided by microsoft for NET client (https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-net-client) into your shared code.

SQLite Compact framework

I have both PC and Mobile application using SQLite. I have installed and used dll version 1.0.66 and when I have update my dlls to 1.0.85 from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and I can see PC program working with SQLite database very well but compact framework seems didn't like it.
I did add System.Data.SQLite and when I try to compile it I get
Error 1 The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
I did remove and add System.Data reference but it didn't work. I removed System.Data.SQLite (1.0.85) and added reference again but chose 1.0.66 one then it worked.
I am really confused, why I cant use the latest verion of the reference/dll? Do I have to always have to use the old version on compact framework ?
Thanks for any help.
A public key token of b77a5c561934e089 means that you're referencing a desktop assembly. You must reference a Compact Framework assembly in a Compact Framework application. Those downloads are near the bottom of the page you reference.

Adding project reference in visual studio

I added a project reference of my Business Logic project to my console application. I can reference the project and its classes in the code of my console application. Weirdly, when I build the project, the build fails and the classes which referenced says Type is not defined.Has anybody come across an issue like this?
You have to import name space in your console application class where you are trying to use the business logic application class.
I have selected the incorrect target framework .net framework client profile 4.0 where it should be .net framework 4. Issue rectified and now I can build the project.

Resources