简体   繁体   中英

Can't find Namespace in Solution with multiple Project with same Namespace

I got the following Solution: There is a Shared Project with a class:

namespace Xamarin.Forms.Lib.Controlls
public class A{
}

And I got an Android Project where I also got the Namespace namespace Xamarin.Forms.Lib

Now when I want to consume the class A in the Andorid Project I got the error, that the namespace could not be found. I am wondering why... it drives me crazy.

Here the exact errormessage if you understand german:

C:\Development\Git\Dev\Lib\Xamarin.Forms.Lib\src\Xamarin.Forms.Lib.Test
\Xamarin.Forms.Lib.Test.Android\MainActivity.cs(9,25,9,34): error CS0234:
Der Typ- oder Namespacename "Controlls" ist im Namespace
"Xamarin.Forms.Lib" nicht vorhanden. (Möglicherweise fehlt ein 
Assemblyverweis.)

It would be nice if anyone got an answer for that problem.
Notice that the share project is an .netstandard 2.0 and the android project is mono71

It's not the problem with the same namespaces, your Android project's name space is Xamarin.Forms.Lib , which is conflict with the package's namespace of official Xamarin.Forms.

So if you try to create a Xamarin.Android project for example named "Test.Android" and then create a shared project named "Test.Android.Controls", and correctly add reference, you will find that it's able to find class A under shared project from your Android project as normal.

I suggest to change the namespace of your project.

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