Ambiguous reference intellisense error from Resource.Designer.cs

后端 未结 1 962
暖寄归人
暖寄归人 2020-12-15 04:54

I am running into a peculiar bug when developing on Visual Studio 2017 that I have been able to ignore for a while, but is now beginning to really bug me.

相关标签:
1条回答
  • 2020-12-15 05:27

    6/6/2018 Update

    If you have ReSharper, you most likely will be able to disregard my per-project solution described below and, instead, simply install the latest version (currently ReSharper 2018.1.2). Apparently, the underlying issue was caused by a bug in a previous version. Upgrading resolved the issue for me.

    See youtrack.jetbrains.com/issue/RSRP-469636 for more information.

    Thanks to @davidbauduin over at Xamarin Forums for this information.


    I believe I have figured out the underlying issue and have a viable solution.

    Solution

    Add the following to the <PropertyGroup> section in your .csproj file:

    <AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
    

    Reason

    While previous versions of Visual Studio had that feature turned off by default, the latest VS2017 update (15.7.3) has it turned on. That feature generates a second Resources.Designer.cs file that results in the ambiguous reference issue.

    You can verify by hovering over the resource constant with the Intellisense error, right-clicking, selecting "Go To Definition", and selecting the 1st item, which takes you to a Resource.Designer.cs file. If you repeat, but select the 2nd one, you'll be taken to a different Resource.Designer.cs file. One of these points to the obj\Debug\designtime\Resource.Designer.cs file. By setting that feature to False as described above, that Resource.Designer.cs file in the obj\Debug\designtime path will not be generated.

    Information Regarding the AndroidUseManagedDesignTimeResourceGenerator Feature:

    https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#design-time-builds-managed-resource-parser

    https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#design-time-builds

    Hope this helps!

    0 讨论(0)
提交回复
热议问题