Resharper shows error and no Intellisense in .Net Standard Projext with Xamarin Forms Xaml
Just bought Resharper and tried to use it in Visual Studio 2017 15.5.2 With Resharper 2017.1.3.
In a newly created Cross Platform project (Xamarin Forms) and .Net Standard Project for shared code, Resharper shows two types of errors:
#1 No Intellisense at all inside .xaml files
#2 Xaml Files are not recognized as partial classes and Resharper shows errors like: InitializeComponents() Method not found and also does not find e.g. the App Class...
It works fine, when the files are placed inside a Shared Project instead of .Net Standard Project
Is this a known Issue? Any workarounds? I really needed this. And this is the reason why I bought it in the first place :-(
Please sign in to leave a comment.
K, just tried to change the Project:
-> legacy PCL Project works like expected
-> .Net Standard 1.4 or 1.6: No Resharper errors show up, but Intellisense and Navigation to Definition in XAML files still does not work
Ups, just saw, that there was an update of Resharper available (2017.3.1). This solved the Intellisense Issue -> nice!
However, an Error at every InitializeComponents() Method for a xaml View shows up:
Version:1.0 StartHTML:000000216 EndHTML:000000613 StartFragment:000000332 EndFragment:000000575 StartSelection:000000332 EndSelection:000000575 SourceURL:file:///C:/Users/tillb/AppData/Local/Temp/Gewadew.txt
Maybe it has something to do with the 3 Startup Projects (Android, Ios, Uwp)
Hello!
Thank you for the feedback.
Could you reproduce the issue in newly created solution? Is there a chance you could provide some demo solution for us?
Thank you.
@till updating to the latest Resharper on VS 2017 solved the same issue for me.
I am still getting this with 2017.3.1 using NetStandard. Also, in my view models, any property accessed only in XAML is shown as unused by Resharper. For example:
C#:
public bool DoSomething{get;set;}
XAML:
<Label IsVisible={Binding DoSomething}"/>
This causes Resharper to tell me that DoSomething is never used.
Hello Brian!
Thank you for the feedback.
Could you please specify what error you're getting? Do you mean error on InitializeComponents()?
Concerning binding issue - unfortunately I cannot reproduce it in newly created Xamarin Forms project.
It will be very helpful if you could provide some sample solution introducing the issues you've experienced.
Thank you.
Angelina, since I do programming for others, I am contractually bound to NOT share code. I would be happy to do a screen-share though...
Thank you for the reply, Brian!
So aren't you able to reproduce problem in newly created solution?
Could you please try clearing caches as described in this article.
Thank you.
clearing the cache did not work.
In XAML, I get Field (control name) is already declared with I give an element an x:Name.
And in code-behind InitializeComponent() show "Ambiguous invocation"
And all x:Name-declared elements show "Ambiguous reference"
I am opening a support ticket...
Same problem here. Can't reproduce it in new project.
JetBrains ReSharper Ultimate 2017.3.2 Build 111.0.20180201.63358
ReSharper 2017.3.20180201.111630
Visual Studio Community 2017 (version 15.5.27130.2026).
Errors disappeared when I cleared Resharper cache and removed .vs and /bin /obj folders in all projects (.net standard, Android, iOS and UWP).
After rebuilding solutions errors are back, but now it is enough to clear Resharper cache and restart VS.
Even after clearing caches and restarting Studio, the error persist. Also removing bin/obj folders did not help. Even when cloning the complete repository to a new location. The errors show on all devices. Its exactly the 2 error types, that @Brian Limkemann mentioned:
- XXX\Views\AboutPage.xaml.cs:14 Ambiguous invocation:
void InitializeComponent() (in class AboutPage)
void InitializeComponent() (in class AboutPage)
- XXX\Views\MainPage.xaml:12 Field xxx is already declared.
.Net Standard 2.0, Xamarin.Forms 2.5
Visual Studio 15.5.6
Resharper 2017.1.3
Hello everyone!
We are really sorry you're experiencing the specified problem with ReSharper.
However we cannot reproduce it on our side, so if somebody could provide solution for which the problem is reproduced we'll be very grateful. It can be submitted privately via 'Submit a request' form in the top of the page, we can also sign NDA if needed.
Thank you.
This error also happened to me.
I could reproduce it.
My Setup:
VS2017: 15.5.7
Resharper: 2017.3.2
CodeMaid: (some version)
Prism Template Pack: 2.0.8
In the .net standard project:
Xamarin.Forms: 2.5.0.280555
Prism.Unity:Forms: 7.0.0.362
How to get the error:
File -> new Project -> Prism -> Prism Blank App (Xamarin.Forms) -> Container Unity, every OS
Project Configuration: Debug -> Start on real Device
Project Configuration: Release -> Start on real Device
Now the Error Appeared in the .net standard Project
Visual Studio 15.7.1, Resharper Ultimate 2018.1 built on 2018-04-14
New Project -> Cross Platform -> Xamarin Forms, All Platforms, .NET Standard
Build the new solution with Android as the Start Up project - VS doesn't list any errors but InitializeComponent is red and the red scroll bar marker is present in MainPage.xaml.cs. Screen shot below.
Create a MainModel.cs that implements INotifyPropertyChanged (Resharper Annotations included) - added two test properties TestString and TestBool with change notification of "Test String" and true (this may not be strictly needed to reproduce but just trying to follow what I assume is one very common general pattern).
public class MainModel : INotifyPropertyChanged
{
private string _testString = "Test String";
private bool _testBool = true;
public event PropertyChangedEventHandler PropertyChanged;
public string TestString
{
get => _testString;
set
{
if (value == _testString) return;
_testString = value;
OnPropertyChanged();
}
}
public bool TestBool
{
get => _testBool;
set
{
if (value == _testBool) return;
_testBool = value;
OnPropertyChanged();
}
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Add BindingContext = new MainModel(); to MainPage.xaml.cs and then start editing MainPage.xaml - with Resharper set as the intellisense in the Resharper options -> NO intellisense for anything (controls/tags or bindings) in editing Main.xaml to:
<StackLayout>
<Entry Text="{Binding TestString}"></Entry>
<Switch IsToggled="{Binding TestBool}"></Switch>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
Project runs as expected.
----
I found this thread because the experience above is the same as I have largely had in a larger Xamarin.Forms project - there was a short period in January (maybe Feb?) when Resharper intellisense was working in the larger project and I was able to include d:DataContext= in the xaml file, use xcc to strip that pre-compilation and get binding intellisense like I am used to in my WPF projects - but it didn't work in all files, I was never sure why, for the most part I now flip the intellisense back to VS for the Xamarin project to at least get some help, but I have been trying to check each VS/Reshaper upgrade to see if intellisense is working in Resharper I have not had any luck.
Given the contents of this thread I was surprised that I was able to repro this so easily. I can give more or upload my test solution used to reproduce the issues but can not share my larger project. I hope this in combination with the reproduction in the message above helps - often hard to guess if it will last but Xamarin.Forms has become important to our dev process very quickly and would love to see great support in Resharper and Rider!
I have the same issue, this is a new Xamarin project and i can reproduce this issue every single time.


Everything is up to date, cleaned, checked, rebuilt etc.
And it does not end there.
This is after i have been able to fix the first issue by changing .xaml file's build action to Content and then back to Embedded resource.
I am late to begin Mobile development with Xamarin and Resharper however, i thought these bugs should have been long gone ?
Visual Studio 2017 15.7.1
Resharper Ultimate 2018.1
I am seeing all of the same issues:
InitializeComponent is Red
Any reference to controls in XAML from .cs file showing Red
No IntelliSense in XAML files
Hello folks!
We've fixed lots of Xamarin.Forms related issues in R# 2018.1.1 EAP build https://www.jetbrains.com/resharper/eap/. Please try it and let us know how it goes.
Thanks!
I didn´t receive an update since 14th of April. I´m still on Version 2018.1
The Problem persists with Visual Studio 2017 15.7.27703.2018
New Project -> Xamarin -> .Net Standard leads to several red underlines despite a green build:
App.xaml.cs:12 Cannot resolve symbol 'InitializeComponent'
MainActivity.cs:17 Ambiguous reference:
int Tabbar (in class Layout)
int Tabbar (in class Layout)
match
@till, you haven't received any updates since the build I pointed out to is EAP build (Early Access Program), so there is no update notification in the release version. So, you need to install it manually.
Thanks!