简体   繁体   中英

Error: The type or namespace name 'Interface' does not exist in the namespace (are you missing an assembly reference)

I am developing an application using Xamarin and got stuck into this error. The error has been generated from my .Droid project while building the solution (Clean Solution is successful). The 'Interface' is a folder which is present inside my Portable PCL project. Basically I want to implement an interface (declared inside my Portable project) into my.Droid project. I have already tried to refer that Interface folder with using keyword but it says does not exist . And since the folder is not getting referenced, all the interfaces inside that folder are also not getting referenced.

The below code is of .Droid project file in which interface has to be implemented.

using ProjectName;
using ProjectName.Interface;
using Xamarin.Forms;

[assembly: Dependency(typeof(FileName))]
namespace ProjectName.Droid
{
    class FileName : InterfaceName
    {
        ....
    }
}

The below code is of one of the Portable project interface file inside Interface folder.

using System;
using ProjectName;

namespace ProjectName.Interface
{
     public interface InterfaceName
     {
          ....
     }
}

When I try to Add Reference of Portable project into.Droid project it says:

Unable to add reference to Portable project. The current project's target is not one of or compatible with the targets of Portable Project.

Please Note:

  1. I am using Visual Studio 2019 .
  2. My Portable project Target Frameworks are: .NET Framework 4.5, ASP.NET Core 1.0, Windows 8, Windows 8.1, Windows Phone Silverlight 8.
  3. My Droid project Target is Android 11.0 (API Level 30 -R)
  4. I have already added Mono.Android.dll file inside Portable as well as Droid project.
  5. I have tried deleting bin and obj folder of both projects but didn't worked at all.
  6. I am unable to add Reference of my Portable project into my Droid project.
  7. Also, all the interfaces inside 'Interface' folder are public .

Any kind of help will be appreciated.

I have solved this problem by myself. I have edited ProjectName.Droid.csproj file and manually inserted reference code for my Portable Project. No need to convert into .net standard at all. All errors are gone. Thank You everyone who contributed. Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM