Reputation: 481
I'm getting this error:
"MyApp\App.cs(7,7): Error CS0246: The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) (CS0246)".
I'm using Xamarin Studio to make a cross platform app via Xamarin.Forms. Whenever I build the basic form project I get this error and I don't know why.
I'm new in Xamarin.
Here is the code of app.cs:
using System;
using Xamarin.Forms; //This is the line where error occurs
namespace FIrstFormProject
{
public class App
{
public static Page GetMainPage ()
{
return new ContentPage
{
Content = new Label
{
Text = "Hello, Forms !",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
},
};
}
}
}
Upvotes: 30
Views: 92166
Reputation: 43
I went to Visual Studio Installer and installed .Net classic apps package (sorry, i don't know exact name, because i have russian version) And it helped me.
Upvotes: 0
Reputation: 1798
The context in my case is that the solution was already compiling previously, yet stopped doing so after changes to the code. In my case all I did was change the XAML file, add a resource and reference said resource in the XAML file. Prior to this Xamarin.Forms
was found, afterwards it was no longer found by Visual Studio for an unknown reason.
Restarting Visual Studio resolved the problem for me.
This is likely only relevant if Xamarin.Forms
was found before and suddenly went missing, a restart is obviously unsuitable in fixing errors with the project setup.
This also sometimes (though not always) occurs when the Xamarin.Forms
NuGet package is changed, i.e. a different one is installed for projects.
Upvotes: 1
Reputation: 1691
I have VS 2019 and I was prompted to update the Android SDK. After doing this I got a load of compiler errors including The type or namespace name 'Forms' does not exist in the namespace 'Xamarin'
After updating my NuGet package to the latest version, the errors resolved (from 4.3.0.947036 to 4.3.0.991211)
Upvotes: 1
Reputation: 116
I had it today in the VS MAC.
Deleting the ".vs" hidden folder fixed it for me.
Upvotes: 3
Reputation: 1601
I have to combine some previous answers:
Upvotes: 5
Reputation: 1778
After removing/reading Xamarin.Forms NuGet package two times and hot having this fixed, I had restarted my Visual Studio(15.9.0) and it worked. This was a brand new solution I created and started having this issue immediately.
Upvotes: 2
Reputation: 1142
Upvotes: 4
Reputation: 1
I had to uninstall and reinstall Nuget Xamarin.Forms in both the Android and PCL library.
Upvotes: 0
Reputation: 41
Select the solution & right click Go to Restore Manage Nuget Packages
Upvotes: 2
Reputation: 601
Do the following:
Upvotes: 9
Reputation: 316
You are ready to work with xamarin.forms :)
Upvotes: 2
Reputation: 645
Look for your Target. Some targets aren't compatible with Xamarin.
Upvotes: 0
Reputation: 2352
MihaMarkic's post here led me to the right answer. For each project in your solution you'll need to do the following:
This is the workflow that got it working on my Mac. I'm not sure what the exact steps are for you PC users out there.
Upvotes: 57
Reputation: 10503
This happened when I removed the Xamarin.Android.Support.v4
and Xamarin.Forms
library in order to downgrade to an earlier version. I got it working again by resetting the Droid packages.config
to:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Android.Support.v4" version="22.1.1" targetFramework="MonoAndroid44" />
<package id="Xamarin.Forms" version="1.4.2.6355" targetFramework="MonoAndroid44" />
</packages>
Then right-click the Droid Packages
folder to Restore missing packages.
The final step is to add the References
> From Packages
to the *.Droid.csproj
<Reference Include="Xamarin.Android.Support.v4">
<HintPath>..\packages\Xamarin.Android.Support.v4.22.1.1\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Platform.Android">
<HintPath>..\packages\Xamarin.Forms.1.4.2.6355\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
</Reference>
<Reference Include="FormsViewGroup">
<HintPath>..\packages\Xamarin.Forms.1.4.2.6355\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Core">
<HintPath>..\packages\Xamarin.Forms.1.4.2.6355\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Xaml">
<HintPath>..\packages\Xamarin.Forms.1.4.2.6355\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Platform">
<HintPath>..\packages\Xamarin.Forms.1.4.2.6355\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
</Reference>
Upvotes: 0
Reputation: 9923
Do the following
3.Go to control panel select programs and features and right click xamarin choose repair. 4. Start xamarin studio again.
Upvotes: 0
Reputation: 481
I just had to add the Xarmin.Forms.Addin.dll in app's references. :) (Thanks @sam holder your hint in the comments led me to the answer.)
Upvotes: 6