Ambiguous reference error

Completed
I am using VS 2022 17.6.5 with ReSharper 2023.1.3
 
I have a the following projects in .NET MAUI solution:
  • project Contacts.Core (MAUI class library)
  • project Contacts.UseCases which references Contacts.Core (MAUI class library)
  • project Contacts.Plugins.DataStore.InMemory (MAUI Class library) which references Contacts.Core and Contacts.UseCases
  • project Contacts.MAUI (MAUI Application) which references all above projects
The file MauiProgram.cs in Contacts.MAUI project contains code like this:
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
//...
builder.Services.AddSingleton<IContactRepository, ContactInMemoryRepository>();
builder.Services.AddTransient<IViewContactsUseCase, ViewContactsUseCase>();
//...
}
}
The solution compiles and runs without errors. However, Visual Studio 2022 editor displays the mentioned two lines (and all similar) as errors. These errors are only visible in the editor as red squiggly lines, they are not visible in Error List panel.
 
For example, hovering the mouse over the word `ViewContactsUseCase` displays error: 
Ambiguous reference: 
Contact.UseCases.ViewContactsUseCase
Contact.UseCases.ViewContactsUseCase
match
 
A workaround is to open ReSharper options, clear caches and reopen VS. However, after building the solution, the errors come back.
 
Another workaround is to remove reference to project Contacts.Core from project Contacts.MAUI. Once this reference is removed, these errors don't appear anymore, at least I haven't noticed them. But I am not sure if this is the right way because in fact the dependency exists, only now it is implicit and I'd prefer to make it explicit. 
 
Is there a better workaround for this?
0
13 comments

Hello bea mar, thank you for your question.

Could you please try disabling "Read solution model directly from project/solution files" in "ReSharper | Options | Environment | General", then reopen the solution? Does it help?

 

0

Indeed, unchecking this option removes the errors in the editor. It seems that also doing the same from right clicking on project in the solution explorer and selecting "Edit Project Item Properties" and "ReadProject Model from Project File" to "True" has this effect (after reopening VS). Either method seems to resolve the issue.

0

Hello bea mar, thanks for the reply.

The case is that the option is intended to be always enabled and if its disabling helps - we have a point to improve as your solution represents some corner situation.

It would be great if you could provide the solution where the issue appeared. You may remove some project parts or methods realization while the issue is reproducible. We can sign a Non-Disclosure Agreement (NDA) if there are some sensitive code or requirements of the rights owner.

As an alternative, it would also be helpful if you could collect additional information as described in the following article. Please upload the information manually to JB server via form or share such information with us using "Submit a request" button. Thanks in advance!

0

Hello bea mar, I'm sorry for the late response.

I downloaded the solution, tried to reproduce with ReSharper 2023.2.1 and the previous one - 2023.1.4, but could not reproduce the issue. I get the following:

Therefore, it would be great if you could collect additional information for us using the following steps:

As an alternative, it would also be helpful if you could collect additional information as described in the following article. Please upload the information manually to JB server via form or share such information with us using "Submit a request" button. 

Thanks in advance!

0

I looked at the problem closer and it turns out that, although disabling the option to read solution model directly indeed removes the errors in editor immediately, they come back when VS in reopened (even though the option is still disabled from previous session).

So, on my computer, the errors appear always in a newly opened solution, despite of the solution model option setting. And then checking or unchecking this option always removes the errors. And then when solution is opened next time, they come back.

Anyway, I uploaded log files from newly opened solution (when the option was previosly disabled or enabled), maybe it will help you somehow to resolve this issue. 

I am not sure whether it is safe to share the upload ID here on this forum?

0

Hello bea mar,

Thank you for collecting additional information for us. 
Could you please use the “Submit a request” button on the upper right corner of this page and mention this link https://resharper-support.jetbrains.com/hc/en-us/community/posts/12552338525074-Ambiguous-reference-error in the Description field?

Also, please attach your log files to the Attachments field. 

This allows us to take a closer look at the case.

Thank you in advance.

 

0

Hello bea mar,

I've got your request and additional files in our internal system. Thank you!

So, let's close this thread and continue further communication in your request.
Have a nice day!

0

Any update on this. I have this or a very similar “ambiguous errors” listing using .net Maui with no actual errors.

1

fwiw:
JetBrains ReSharper 2023.2.2
Build 232.0.20230919.80758 built on 2023-09-19
ReSharper
2023.2.20230920.162346 (up to date)
Environment
Visual Studio Community 2022
Version 17.7.6

0

Hello Axa88888888,

Could you please collect some additional information for us? We'll investigate it.

1. Please run Visual Studio with the following command line: devenv /ReSharper.LogFile C:\log\resharper_log.txt /ReSharper.LogLevel Verbose. After that, reproduce the issue and send the corresponding resharper_log.txt file via the “Submit a request” button on the upper right corner of this page.

2. Also, please attach some screenshots introducing the problem in the “Attachmentsfield. 

Thank you in advance. 

1

Hello Axa88888888,

Thank you for the link. I've got your request and contact you via our support system for further investigation. Thanks.

0

Please sign in to leave a comment.