Resource.designer.cs NOT regenerating in Mono (Xam

2019-04-23 14:53发布

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...

3条回答
叼着烟拽天下
2楼-- · 2019-04-23 15:36

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.

查看更多
冷血范
3楼-- · 2019-04-23 15:40

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

查看更多
叛逆
4楼-- · 2019-04-23 15:59

This work for me:

  1. Open your .designer.cs file and erase all class content, letting only the class declaration empty.
  2. open .xib file or storyboard that give you trouble with your .cs file.
  3. update Identify>Class property of the view that use that .designer.cs class removing, unfocus, focus and setting again the property value.
  4. save
  5. rebuild
查看更多
登录 后发表回答