Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio c# compiler does not notice a changed method name

I have a really strange problem in a c# program:

I have an interface which declares a method and a class implementing this interface. When I change the methods name (in the interface and in the implementation), visual studio compiles the code, but if I run the code, I get a method not found exception. If I manually delete the target dll and recompile the project/solution, all works fine.

However, there are a lot of other methods and properties, also declared in the same interface and implemented in the very same class. If I change the name of one of them, all works fine!

Has anyone an idea, what this can be?

 public interface INode{
    //...
    IEnumerable<INode> Ancestors();
    //...
 }
 public abstract class NodeBase : INode{
    // ...
    public IEnumerable<INode> Ancestors(){

    }
    // ...
 }
like image 440
HCL Avatar asked Mar 08 '26 01:03

HCL


2 Answers

While trying to resolve the problem, I have removed the reference to the problem-assembly from the UI-project and then re-added. From this time on, the issue has been gone.

Sadly, I can not say what the reason for this really strange problem was, and now I have no more the opportunity to look at the issue. It must have been something corrupted within the project, however I can not imagine what this could have been, because really only one method signature was concerned (independent of the position in code and the name of the method).

Thanks to anybody who posted an answer so far (+1), leading me to a solution. I hope I will never see this weird behaviour again! For those having the same problem: try to recreate the references to the issuing project.

like image 92
HCL Avatar answered Mar 10 '26 14:03

HCL


Have you tried doing a Build > Clean Solution/Project?

like image 38
Whyrusleeping Avatar answered Mar 10 '26 16:03

Whyrusleeping



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!