Mando
Mando

Reputation: 11712

Simple DataAccess PCL Library for Monotouch/Android/WindowsPhone

I'm trying to create simple DataAccess portable class library for 3 platforms (ios, android, wp7.5). All I want is to create webrequests, convert data and return it to UI of each platform.

I was able to create library like this (portable) under Mac OS X Xamarin Studio and successfully used it at iPhone app. But then I opened this solution under Visual Studio (to add Windows Phone UI project) it gave me build error with description that it couldn't find System.Net namespace. When I checked portable class targets I was surprised to see there even XBOX selected: enter image description here

When I selected correct targets (MonoDroid/Monotouch/WindowsPhone7.5) I was able to compile but when I start the app I received the following error:

"c:\Downloads\Noname.CrossXam\Noname.CrossXam\Noname.CrossXam.iPhone\Noname.CrossXam.iPhone.csproj" (_RemoteBuild target) (1) -> (_ResolveAssemblies target) ->
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(68,3): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Perhaps it doesn't exist in the MonoTouch profile? ...

0 Warning(s)
1 Error(s)

Same code (same solution) works just fine under Mac OS X with Xamarin Studio. Sample solution is here: https://dl.dropboxusercontent.com/u/19503836/Noname.CrossXam.zip

Please advise.

Upvotes: 1

Views: 546

Answers (2)

Mando
Mando

Reputation: 11712

The issue was in System.Net.dll assembly which is not exists under MonoTouch & MonoAndroid profiles. But that classes are implemented at System.dll under those profile and to make it work you need TypeForwardedToAttribute.

All that type forwarding configuration exists at MVVMCross nuget package which I was able to install only after updating nuget (the last comment from this post: http://slodge.blogspot.com/2013/04/my-current-pcl-setup-in-visual-studio.html)

So there were two issues: 1. Old nuget package manager (update is required) 2. TypeForwardedToAttribute configuration (exists at MvvmCross)

Hope it will be useful for someone.

Upvotes: 1

Roman Kagan
Roman Kagan

Reputation: 464

Have you tried to change target framework to .Net 4.5? You should see Profile104 in your .csproj file

Upvotes: 0

Related Questions