1
votes

I need to use System.Reflection.TypeExtensions in some of my Nuget packages. I want this package to be used within a Xamarin Forms project. According to the nuget package page of System.Reflection.TypeExtensions , this should work with Xamarin.

However, when I compile my Android project for testing purpose, I got this error :

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Reflection.TypeExtensions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?

I cannot figured it out how to fix this error, especially because this package is required by some other that I cannot remove...

Any ideas how to fix ?

Here my project.json/frameworks of my package :

"frameworks": {
"net45": {
  "frameworkAssemblies": {
    "System.Runtime": "",
    "System.ObjectModel": "",
    "System.Linq.Expressions": ""
  },
  "dependencies": {
    "System.Collections": "4.0.11-beta-23516"
  }
},
"dotnet5.2": {
  "dependencies": {
    "System.Collections": "4.0.10",
    "System.Collections.Concurrent": "4.0.11-beta-*",
    "System.ComponentModel": "4.0.1-beta-*",
    "System.Globalization": "4.0.11-beta-*",
    "System.Linq": "4.0.1-beta-*",
    "System.Linq.Expressions": "4.0.11-beta-*",
    "System.Reflection": "4.1.0-beta-*",
    "System.Reflection.Primitives": "4.0.1-beta-*",
    "System.Reflection.TypeExtensions": "4.0.1-beta-*",
    "System.Runtime": "4.0.21-beta-*",
    "System.Threading": "4.0.11-beta-*"
  }
},
"dnxcore50": {
  "dependencies": {
    "System.Collections": "4.0.11-beta-23516",
    "System.Collections.Concurrent": "4.0.11-beta-*",
    "System.ComponentModel": "4.0.1-beta-*",
    "System.Globalization": "4.0.11-beta-*",
    "System.Linq": "4.0.1-beta-*",
    "System.Linq.Expressions": "4.0.11-beta-*",
    "System.Reflection": "4.1.0-beta-*",
    "System.Reflection.Primitives": "4.0.1-beta-*",
    "System.Reflection.TypeExtensions": "4.1.0-beta-23516",
    "System.Runtime": "4.0.21-beta-*",
    "System.Threading": "4.0.11-beta-*"
  }
}

PS : rebooting Visual Studio doesn't fix anything

2
While creating the Xamarin.forms project u Selected PCL or shared project? , In PCL , you don't get access to all .NET pkgs, also some pakgs are not supported because xamarin doesn't target latest nuget version (lastly nuget 2.8.1 is what xamarin is using) - saket kumar
I choose shared project for simplicity - cdie
Can you check and confirm u r targeting to .Net 4.0 or .Net4.5 framework!? - saket kumar
Xamarin is blocked to 4.5, and seeing the project.json, u can see net45 and dotnet5.2, which is the max available for Xamarin - cdie
I have created an android project with shared project preference and i m able to use system.reflection types , so in that case can u remove the suspicious depencies and try to add em again? - saket kumar

2 Answers

2
votes

Figured out what happens : I picked the DLL from the dotnet5.2 output. If I choose the DLLs from net45 folder, I have no compilation issue.

Altough, I have to search why, when create nuget package, it picks the wrong framework and create errors.

0
votes

You have referenced two different versions

  • "System.Reflection.TypeExtensions": "4.0.1-beta-*"
  • "System.Reflection.TypeExtensions": "4.1.0-beta-23516"