❔ 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
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.
Do you have a property and an event with the same name?
Nope, the class only has the event and nothing more
You can't use an event in a conditional statement like that
But how do I check?
It's used like that in the base class
@Wolf argon = new Wolf(); does
this.LobbySlotValueChanged?.Invoke(this, 0);
work?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
This is different from what you have though
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
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?
It's not defined twice, I'm working with an external library. Plus, the only field that gives me that error is that one
It's just defined once
the error is still there, though
have you tried creating an empty project and referencing that field?
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?
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
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?
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!
can you have your delegate and event with the same name?
if you mean delegate type yeah, usually it's not a problem
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.