C
C#16mo ago
Argón

❔ Nonsense Ambiguous Reference

Hi there! I'm habing a problem which is a very odd ambiguous reference that points to the exact same field. Is this normal to happen sometimes in code or am I doing something wrong? If you need more information about the code let me know.
21 Replies
Argón
ArgónOP16mo ago
I am trying to extend a class and fire an event, basically, but when I write its name that exception automatically apears and it confuses me a lot.
Anu6is
Anu6is16mo ago
Do you have a property and an event with the same name?
Argón
ArgónOP16mo ago
Nope, the class only has the event and nothing more
Anu6is
Anu6is16mo ago
You can't use an event in a conditional statement like that
Argón
ArgónOP16mo ago
But how do I check? It's used like that in the base class
Argón
ArgónOP16mo ago
jcotton42
jcotton4216mo ago
@Wolf argon = new Wolf(); does this.LobbySlotValueChanged?.Invoke(this, 0); work?
Argón
ArgónOP16mo ago
Can't verify that since I can't edit the base class directly, so that's why I am writing an extension method Unless I didn't understand what you meant
Anu6is
Anu6is16mo ago
This is different from what you have though
Argón
ArgónOP16mo ago
Yes, because that is the base class I am attempting to write an extension method for I am writing an extension method because I do not have access to modifying that class But when I try to fire the event, I get an ambiguity which makes zero sense
Omnissiah
Omnissiah16mo ago
are you sure beyond every doubt you don't have that member defined more than once? F12 goes directly to the member instead of enumerating it in reference window?
Argón
ArgónOP16mo ago
It's not defined twice, I'm working with an external library. Plus, the only field that gives me that error is that one
Argón
ArgónOP16mo ago
It's just defined once
Omnissiah
Omnissiah16mo ago
the error is still there, though have you tried creating an empty project and referencing that field?
Argón
ArgónOP16mo ago
Yes I just tried and it still happens I was wondering, maybe events can't be fired from outside the class But it wouldn't show an ambiguity error, right?
Omnissiah
Omnissiah16mo ago
wtf how can this happen is there any weird reference? copy here what dotnet/csc is saying, it should point to both the assemblies that declare this member
SinFluxx
SinFluxx16mo ago
are you able to $paste any further code to get a clearer picture of what's going on? Is the base class private or can it be shared?
MODiX
MODiX16mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
SinFluxx
SinFluxx16mo ago
can you have your delegate and event with the same name?
Omnissiah
Omnissiah16mo ago
if you mean delegate type yeah, usually it's not a problem
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server