Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource.designer.cs NOT regenerating in Mono (Xamarin Studio)

I'm currently developing an app with Mono, I recently updated to Xamarin Studio 4.0.8, and was having problems with the design elements not being added to the solution.

I tried to edit manually the designer.cs, and later on I erased it, hoping the program will regenerate it again, with the layout changes.

I have tried:

  • Rebuilding it

  • Cleaning and rebuilding

  • Erasing the file through the file explorer

And it still doesn't regenerate properly, Xamarin creates the Resource.designer.cs but it's empty, and when compiling it returns this:

Error CS0103: The name 'Resource' doesn't exist in the current context (CS0103)

Help please...

like image 436
webnator Avatar asked May 28 '13 14:05

webnator


People also ask

What happens if I delete resource designer in Xamarin Studio?

Show activity on this post. As recently as Xamarin Studio 5.6 (build 273) with Xamarin.Android 4.18.0, if you have manually deleted the Resource.designer.cs file from the project, rebuilding will regenerate Resource.designer.cs, but will not add it back into the project.

What is wrong with Xamarin Studio?

A bug in Xamarin.Studio 5.1 previously corrupted .csproj files by partially or completely deleting the xml code in the .csproj file. This would cause important parts of the Android build system (such as updating the Android Resource.designer.cs) to fail.

How to rename a project in Xamarin?

You can rename your project by using find/replace, but the resources file will use whatever is set for 'default namespace' in the Main Settings and will continue to revert to this name even if you manually edit the Resource.designer.cs file in or out of Xamarin. Show activity on this post.

How to generate the resource designer file?

The resource designer file is only generated when there is a change in the resource I applied following steps to generate the required resource.designer.cs file * Added a dummy image in the resources * Cleaned the project * Rebuild the project New resource.designer.cs generated. Show activity on this post. Show activity on this post.


2 Answers

Lots of time having this issue. What i did:

  1. Remove "resources.designer.cs" using Xamarin (secondary button->remove).
  2. Go to command line (finder on Mac/Explorer on Windows) and delete manually the file (be sure you deleted it).
  3. Go to Xamarin, clean->build (this will regenerate the resoruces.designer.cs).
  4. As you remove the file from the project, you have to add it again. secondary button over project-> add Files->select Resources.designer.cs (tipically on /Resources folder).
  5. Make sure the "Build Action" of the Resource.designer.cs file is Compile (sometimes it takes a different build action by default).
  6. Clean and build.

At least it have worked most of the time.

like image 108
Diego Andrés Díaz Espinoza Avatar answered Oct 11 '22 04:10

Diego Andrés Díaz Espinoza


I had this happen a while back. If you right click on your XML file, and click properties. Make sure that the Build Action is set to "AndroidResource"

If I recall correctly that fixed it

like image 33
cheezy Avatar answered Oct 11 '22 03:10

cheezy