Reputation: 1061
At some point project identity was modified and i reflected that in code by renaming the solution, project, assembly and default namespace, with all corresponding folders - all instances of a name that i could find. I also used Notepad2 to fix the contents of solution and project files.
Note: Namespace in code was changed using VStudio's Rename feature.
Since then every time Resource.Designer.cs
file gets re-generated, it pulls the old namespace in (?!), breaking the reference to automatic Resource
class, which defines resource IDs:
And in some cases it will immediately get re-generated again - you guessed it - with the old name, but sometimes(!) it will accept my edit, save it and let the project be actually compiled and run:
I've tried Clean and Rebuild commands multiple times for both project and solution, restarted VStudio, rebooted Windows.. No dice, it keeps happening.
App's TargetPlatform is 7.1, MinimumVersion is 4.3, all 5 supported architectures are enabled. VStudio - 15.5.4, .NET - 4.7.03056, Xamarin - 4.8.0.757, Xamarin.Android SDK - 8.1.3.0.
Just found this in the Similar Questions list: Ambiguous reference intellisense error from Resource.Designer.cs. Looked promising, so i did the following:
\bin
and \obj
subfolders in File Explorer.Resource.Designer.cs
, so it has correct (new) namespace: J7987ca.J7987ca.csproj
, as advised.I guess, i can start with a clean slate and re-create entire solution from scratch with a new name, but for the Love of God, why do i have to do that? And where does it pull the old name from?!
Upvotes: 3
Views: 1762
Reputation: 794
You also need to change it in the assembly line, not just the namespace.
For example
[assembly: global::Android.Runtime.ResourceDesignerAttribute("com.companyname.TestBottomSheetDialog.Resource", IsApplication=true)]
namespace com.companyname.TestBottomSheetDialog
Upvotes: 0
Reputation: 424
I'm a little late to this, but I ran into this issue recently and was able to fix it by updating both <RootNamespace>
and <AssemblyName>
tags in the Android csproj
file.
Then cleaning the sln
and closing Visual Studio and deleting bin
, obj
, and the old Resource.Designer.cs
file (from the directory using the File Explorer and not by removing it from the csproj
).
Upvotes: 2
Reputation: 1061
My last image shows <RootNamespace>J7980ca</RootNamespace>
- the old name. I did not pay much attention to re-check that tab after re-opening solution, because such an awful glitch would never occure to me: i never had problems saving values in those VS "dialogs" previously.
It turns out that changing Default Namespace in Project Properties does not take effect!
I verified it twice.
Mind you, Assembly Name was saved, so i'm at a loss of wits to explain, how all this is happening.
As soon as i edited .csproj
in Notepad2 re-opening the solution happily put proper namespace into Resources.Designer.cs
and allowed compilation.
Upvotes: 2