Forum Visual Studio

Newly added Class Not Found

I'm missing something very basic.

I open a new Solution in Xamarin Studio - A Mobile Apps - Blank App (Xamarin.Forms.Shared)

Then I click on my project name where the App.cs file is and I say add new file and add a new empty class.

Then I try to instantiate that class in the app.cs file:

public class App
    public static Page GetMainPage ()
        EmptyClass em = new EmptyClass (); //RIGHT HERE
        return new ContentPage { 
            Content = new Label {
                Text = "Hello, Forms!",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,

But I get a compilation error: c:\Users\Joshua\Documents\Projects\Test\Test\App.cs(4,4): Error CS0246: The type or namespace name 'EmptyClass' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Test.Android)

The namespaces are the same.

If I move the content of the EmptyClass file into the app.cs file it works fine. It's like its just not compiling the separate file?


  • mattwardmattward GBMember Xamurai

    It looks like you are hitting this bug. The workaround in the bug report is to remove the reference to the Shared Project and add it back again. I think you should also be able to fix it be closing and re-opening the solution.

  • JoshuaPerinaJoshuaPerina CAMember

    That was it. Thank you very much!

Sign In or Register to comment.