"Namespace not found" in VS Mac, works fine in XS Mac?

Hi, hope someone more clever than me can assist with this...

I'm experiencing namespace not found issues in Visual Studio for Mac (Preview 5), however the same project compiles and works fine in Xamarin Studio... description below:

  • Xamarin Forms PCL (Profile 111) Project (currently only targetting iOS devices)
  • Using Akavache as well so settled on Profile 111
  • Installed Refit (had to install Netstandard.Library first)
  • Configured Basic Interface and some Test code which all works perfectly using Xamarin Studio/Mac... compiles, runs, works.

However on Visual Studio for Mac (Preview 5) I get "The type or namespace Refit could not be found, are you missing an assembly reference" with the the "using Refit" statement highlighted... (which is odd seeing as through VS added the statement for me using the Quick Fix?)

If I close Visual Studio for Mac and open/compile the project in Xamarin Studio all works fine.

Any idea as to what could happening here and how I could sort out the issue in VS/Mac?

Thanks

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @LeonPotgieter

    Thanks for the report. I was able to reproduce this error and noted this in the errors pane:

    /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Warning MSB3274: The primary reference "Refit" could not be resolved because it was built against the ".NETPortable,Version=v5.0" framework. This is a higher version than the currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile111". (MSB3274) (TestRefit)

    I don't think Xamarin Forms supports .NET Standard out of the box at this time. See this blog post:
    https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/

    And a bug report filed:
    https://bugzilla.xamarin.com/show_bug.cgi?id=49275

    Also this issue on the dotnet/roslyn repo may be relevant:
    https://github.com/dotnet/roslyn/issues/11067

  • LeonPotgieterLeonPotgieter ZAMember ✭✭

    Thanks for the input Jon,

    Did you reproduce the issue using VS/Mac?

    You mention that Xamarin Forms doesn't support .NET Standard, but I'm able to compile and run the same project just fine in Xamarin Studio/Mac? And the Refit code works perfectly... it's only in Visual Studio/Mac that I have the namespace problem.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited April 2017

    Yes, I could only repro with VS4Mac.

    And sorry, I just realized that bug report was filed as a private bug report. There is a comment on it from a Xamarin engineering team member that may help you here:

    Xamarin.Forms does not explicitly support .NETStandard so the error message in VS and Xamarin Studio reported by NuGet is correct.

    To allow Xamarin.Forms to be installed into a .NETStandard project that uses a project.json file you need to add an imports section to indicate that you consider a particular PCL profile to be compatible.

    {
        "dependencies": {
            "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
            "NETStandard.Library": "1.6.0"
        },
      "frameworks": {
            "netstandard1.5": {
              "imports": [
                    "portable-net45+wpa81+wp8+win8"
              ]
            }
      }
    

    }

    https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/
    https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/

    If none of the above helps, then I will get a new bug report filed. Let me know. use @JGoldberger to get my attention. :-)

Sign In or Register to comment.