Resharper: Ambiguous Invocation

2019-08-07 03:48发布

问题:

Using Resharper I get the following message:

Ambiguous InvocationSolution ITicket.sln Project ITicket ITicket\frmMainTicket.cs:530 Ambiguous invocation: void DisableAllFields() (in class frmMainTicket) void DisableAllFields() (in class frmMainTicket) match

I am new to coding and could use a little help. If I understand this correctly it is basically saying that I am calling a method and it is unsure what method I should use? I have never used Resharper before. Maybe I am confused on what Ambiguous Invocation is, I have done some research on it though. Thank you in advance.

From the code:

        private void SetViewForBugnetTicket()
    {
        DisableAllFields();

        btnSendBugnetDev.Enabled = false;
    }

Method:

        private void DisableAllFields()
    {
        tbSubject.Enabled = false;
        cmbCreatedBy.Enabled = false;
        cmbDepartment.Enabled = false;
        cmbCompany.Enabled = false;
        dtpCreatedOn.Enabled = false;
        dtpAssignedOn.Enabled = false;
        dtpDueDate.Enabled = false;
        cmbAssignedBy.Enabled = false;
        cmbMainTech.Enabled = false;
        cmbStatus.Enabled = false;
        cmbPriority.Enabled = false;
        cmbCategory.Enabled = false;
        cmbTicketType.Enabled = false;
        radBtnNoTraining.Enabled = false;
        radBtnYesTraining.Enabled = false;
        btnAddNoteDev.Enabled = false;
        tbNoteAdd.Enabled = false;
        rtbDescription.Enabled = false;
        tsBtnSaveTicket.Enabled = false;
        btnSetStatus.Enabled = false;
        btnResolve.Enabled = false;
        tbResolution.Enabled = false;
        cmbResolution.Enabled = false;
        btnBrowse.Enabled = false;
    }

回答1:

We had this problem. It occurred in R# 9.2 VS2013 and VS2015 w/ VB.net. We had local variables in a method declared as

Dim Yield as Decimal

Later, an assignment was made.

Yield = CDbl(txtFoo.Text)

The fix is to qualify the token which is a reserved keyword with the characters [ and ]

Dim [Yield] as Decimal
[Yield] = CDbl(txtFoo.Text)

Aside: Yes. It was actually CDbl. The confusion between Double and Decimal abounds in this codebase. It probably needs to go on daily WTF.