Bug 61060 - The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) .NET Standard
Summary: The type or namespace name 'App' could not be found (are you missing a using ...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 8.1 (15.5)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-12-09 01:45 UTC by tim.rossiter99
Modified: 2018-05-08 23:28 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 61060 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description tim.rossiter99 2017-12-09 01:45:56 UTC
I made a Xamarin.Forms project with a .NET Standard 2.0 Library and I am getting the same error on all 3 of my projects; Android, iOS, UWP. 
This is happening before I have edited any code, just clean setup. 

But on an older project with a PCL library there's no error, it is able to find the reference to the library. 
Even if you clean and rebuild the project to clear the error, project never is able to recognize the App() or its containing class has any references.
Its the same bug as Bug 56538, but doesn't seem to be resolved as it's marked? 

Error	CS0246	The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

errors in MainActivity.cs
LoadApplication(new App()); 

App.xaml.cs, should have 3 references.
- references
public App ()

			MainPage = new BlankApp1.MainPage();

Version Information:
Microsoft Visual Studio Professional 2017 
Version 15.5.0
Microsoft .NET Framework
Version 4.7.02053

Installed Version: Professional

Visual C# 2017   00370-10003-35475-AA496
Microsoft Visual C# 2017

ASP.NET and Web Tools 2017   15.0.31120.0
ASP.NET and Web Tools 2017

Mono Debugging for Visual Studio   4.8.4-pre (3fe64e3)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61710.120
Microsoft SQL Server Data Tools

TypeScript Tools   15.5.11025.1
TypeScript Tools for Microsoft Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.27128.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin (4a1f0ea)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.8.182 (76aa1723e)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK (HEAD/9cfa7836b)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK (c4240f3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 1 tim.rossiter99 2017-12-09 02:06:36 UTC
I've tried creating new classes in both the android project and the .net standard library and i am not able to get the android project to recognize any references from the .net library.
Comment 2 Jon Douglas [MSFT] 2017-12-13 00:08:25 UTC
Hi Tim,

The other bug seems related to the Xamarin Live Player. If it's possible, please attach a reproduction project where you are seeing this issue. From past experience I believe you need to compile the "Shared" project first and then the platform projects when it comes to Xamarin.Forms. i.e. Compile the PCL or NetStandard library first, and then the platform.

Can you also include steps of how you are reproducing this scenario?

Perhaps in the future this can be resolved with Design Time Build work.
Comment 3 Damian Lord 2017-12-14 13:40:19 UTC

I think I have same problem.  I had a Xaramin Forms PCL project with Android & iOS projects.  In the PCL project I have an Interface (namespace DiaryManager.Persistence).  In the Android & iOS projects I created a Class from that Interface, and both projects successfully referenced the DiaryManager.Persistence namespace.

After recent VS2017 updates I no longer had the PCL option so am trying to use .NET Standard (as per guidelines).

I've created the exact same setup (DiaryManager.Peristence namespace in Shared project) but neither the Android or iOS projects can see this namespace now (which they could when using PCL).

I get a "namespace could not be found, are you missing a directive or assembly reference?" error.

Both the Android & iOS projects have references to the DiaryManager Shared project but it seems they cannot see the namespace(s) within that (at least not ones below the top-level).

Can I just get my PCL option back as that was a lot easier!?!?

I noticed the .NET Standard Shared project does not have an AssemblyInfo.cs file (which the PCL did).  Would re-instating this help??

Would be great if either the .NET issue could be resolved or the PCL option accessed (so I can created PCL project instead), as this has broken my development now which I'm contracted to complete in the New Year :(

Comment 4 Damian Lord 2017-12-14 15:18:50 UTC
I've managed to resolve my issue by doing the following in the .NET standard/Shared project:

- Create folder named properties
- Copy old PCL project AssemblyInfo.cs file into properties folder
- Amend details to match new Solution/Project
- Rebuild

Now my Android and iOS classes can see the DiaryManager.Persistence namespace in the Shared project and use the Interface I've created.

Any thoughts?

Comment 5 Nicolas Hinze 2018-05-08 23:28:28 UTC
I encountered the same issue. I finally figured out that I needed to reference my .Net Standard Project from my iOS project.