3

Here is the situation. My ASP.Net Application's solution has 3 projects A, B and C. B contains a function (eg : testfunction) which is used by Pages in A and C. Now for a certain requirement for Project C I need to make a change in testfunction. In order to accomplish this I added a optional parameter with a default value which was passed from C. I compiled my code and moved it to server which was the Dll's from B and C. In my testing the requirement was working worked fine. But when the part of application which involved project A invoking the testfunction was called it came up with an error (Method not found). I could'nt figure out why A should break.I just recompiled the DLL from A and moved it to server and error was gone.

My question is Why I had to compile the DLL of A when I did not change the way I call from A?

Nikhil
  • 41
  • 4
  • 3
    Possible duplicate of [Does adding optional parameters change method signatures and would it trigger method missing exception?](https://stackoverflow.com/questions/30317625/does-adding-optional-parameters-change-method-signatures-and-would-it-trigger-me) – GSerg Jun 15 '17 at 18:43
  • You might also like [A definitive guide to API-breaking changes in .NET](https://stackoverflow.com/q/1456785/11683) – GSerg Jun 15 '17 at 18:45

1 Answers1

0

It's more a guess, but i'd assume it's because dll "A" searches for specific method "signiture" like:

B.testfunction(Integer,String)

not

B.testfunction(Integer,String,[String])

that is different method.

You cud test this by leaving original method as it was, and adding new overloads method like this:

Public Overloads Sub testfunction(p1 As Integer, p2 As String)
    testfunction(p1, p2, Nothing)
End Sub
Public Overloads Sub testfunction(p1 As Integer, p2 As String, p3_notOptional As String)
    'Do the thing.
End Sub

If that's correct, "A" should not need recompiling anymore.