Skip to content Skip to sidebar Skip to footer

Prexisiting Dlls (.net 4 Framework) Issue With Mono For Android

I am creating a fresh Mono for android application using http://xamarin.com/monoforandroid I selected Mono for Android Application using Visual C# option. My Android target versi

Solution 1:

The problem here is that you're trying to reference a .NET 4 DLL from a project that isn't .NET 4. Mono for Android uses its own profile for .NET, which is very similar to that of Silverlight (but not exactly the same). While it's possible that adding a DLL compiled for a different profile will work, it's very risky as you will probably run into problems at runtime where your app will crash, due to something being missing from the Mono for Android profile.

The best answer right now is to create a Mono for Android class library, link in the appropriate files from the library you want to use, and reference that. This will give you compile-time checking that you're not using anything unsupported by the Mono for Android profile, and help keep you more sane in the long run. I have an old blog post up here that talks about how to link files across projects.

That said, in this case you're in luck because someone else has already done that last part for you! Check out this fork of Json.NET which provides versions for MonoTouch and Mono for Android.

Solution 2:

The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?

It's not particularly strange - that dialog box was written by Microsoft, with its own project types in mind. It sounds like Mono for Android doesn't have the same options available.

I strongly suspect you'll just have to use a version of JSON.NET targeting .NET 3.5.

(Having said that, Mono for Android claims to support "dynamic language features" which sounds like it should be targeting .NET 4. Odd. I suspect the fix is the same though.)

Post a Comment for "Prexisiting Dlls (.net 4 Framework) Issue With Mono For Android"