Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the name resources does not exist in the current context Xamarin

public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);
            EditText val1 = FindViewById<EditText>(Resource.Id.txtuser1);
            EditText val2 = FindViewById<EditText>(Resource.Id.txtuser2);

Error :

The name 'Resource' does not exist in the current context.

like image 222
arshisaini Avatar asked May 30 '16 03:05

arshisaini


2 Answers

I was facing the same issue today in my Xamarin application. I tried the following things

  1. Clean the solution and rebuild
  2. Close Visual Studio and open again
  3. Delete the obj and bin folder and rebuild the project

None of the above things worked for me. The real issue was because of that the file Resource.Designer.cs was excluded from my project and including that to the solution fixed the issue for me.

enter image description here

Hope it helps

like image 61
Sibeesh Venu Avatar answered Sep 22 '22 13:09

Sibeesh Venu


I was so resolved (by visual studio)

  1. Remove 3 line

    SetContentView(Resource.Layout.Main);
    EditText val1 = FindViewById<EditText>(Resource.Id.txtuser1);
    EditText val2 = FindViewById<EditText>(Resource.Id.txtuser2);
    
  2. Build -> Clean

  3. Build -> Rebuild
  4. rewrite remove 3 line
like image 44
Andromer Avatar answered Sep 26 '22 13:09

Andromer