The name 'Resource' does not exist

DavidLLLDavidLLL Member
edited October 2018 in Xamarin.Android

I have just created a project using visual studio 2015 enterprise. Seeing the code indicates an error in red lines but at the time of compiling it says that supposedly there are no errors but I know that if I start programming and adding lines of code at some point it will send me errors. Could anyone help me please ?

Answers

  • eubikeubik ✭✭ Member ✭✭

    Have you tried cleaning everything and then building it again? Or manually deleting your bin and obj folders and then building again?

    Also, although I am using visual studio 2017, I have found that when in debug mode if I'm cleaning/building/deploying with c# files open in the main window, it'll throw some weird errors. For me it's usually App() or InitializeComponent() does not exist. Not sure if what I suggested will help you, but it helped me with seemingly random errors.

  • jezhjezh Xamurai Member, Xamarin Team Xamurai

    Could you try to delete the bin folders and the obj folders and rebuild it ? If it doesn’t work ,try to restart the VS .

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    I've had this same problem.. it's extremely annoying. My best advice to you, using xamarin, is to make archive copies ALL THE TIME.. every hour or so make a copy. One of the most frustrating things about Xamarin is that it will randomly throw errors like this and then I have to back up to an old project. I've seen this exact same thing when I had changed nothing in the actual project that would remove the reference and all the sudden the project won't compile.

    Another thing, 2015.... you should be using 2017 with every package and update installed if you're going to be using xamarin.

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    @jezh said:
    Could you try to delete the bin folders and the obj folders and rebuild it ? If it doesn’t work ,try to restart the VS .

    that's not a bad idea. seeing as how I've seen this problem occur after debugging.

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    @eubik said:
    Have you tried cleaning everything and then building it again? Or manually deleting your bin and obj folders and then building again?

    Also, although I am using visual studio 2017, I have found that when in debug mode if I'm cleaning/building/deploying with c# files open in the main window, it'll throw some weird errors. For me it's usually App() or InitializeComponent() does not exist. Not sure if what I suggested will help you, but it helped me with seemingly random errors.

    not bad advice but this won't work for the error he's getting. I had the same error and tried that to no avail.

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    ^^(simply cleaning the project) .. I hadn't tried deleting obj and bin ... that actually might work.
    also, why can we not edit our posts on here? I have to spam to make corrections

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    Someone told me how to fix this over the weekend and it worked. Find the resource.designer.cs inside layout. Make a backup of the file, and then delete it. Clean the solution, then rebuild, the file will re-appear but you need to re-add it into the project using right click > add > add existing item. Then clean and rebuild again.

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭
    edited June 25

    Tried all this. Doesn't work.

    You know, all I wanted to do is add a damn dialog box to the app; to move some text boxes to the dialog box. If this were a Desktop app in Windows I could do this in like an hour or less with either Winforms or WPF. I mean, trivial. But with Xamarin, and yes, it's brilliant on the back end, 3 days of screwing around with projects. Starting from a new project, gradually adding this and that, compiling, backing out, starting a new project, etc. I mean like perhaps taking several 100x as long and now I get The Name 'Resource' doesn't exist in the current context.

    I mean, did the Xamarin devs ever get this? There is no work around, apart from, YET AGAIN, starting with an empty project and YET AGAIN gradually adding stuff, recompiling, deploying, waiting for more errors. Like 1 hour max in WinForms vs days and days of suffering with Xamarin. Makes me almost wish I learned Kotlin or something. Very disappointing.

    Literally for the fifth time I'm starting from scratch again. Constantly get "The name 'Resource' does not exist in the current context."

    AND YES, I've deleted the bin and obj folders and Resource.Designer.cs. Exited VS, counting to 20, and restarted. I mean, really?

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭

    It was a namespace issue. The namespace value is stored in the Resource.Designer.cs (among other places). I changed the namespace but didn't realize it was also in that file. Once I fixed it, the problem disappeared. Now my app (without much code; just the axml) can be loaded into the emulator.

Sign In or Register to comment.