79140113

Date: 2024-10-30 07:47:01
Score: 0.5
Natty:
Report link

Yes, this happens because when you compiled against V2.0.0, the compiler tied 'P2' specifically to class 'B'. In V1.0.0, 'P2' lives in A instead, so at runtime, .NET can’t find 'B.P2', and you get an error.

Even though it seems like it shouldn’t matter where P2 is, the compiler expects it exactly where it was when you built the code. Since P2 is in a different class, .NET sees it as missing.

One workaround is using reflection, which lets you check for 'P2' at runtime without caring if it’s in 'A' or 'B'. However, reflection can be slower and a bit messier. Another option could be setting up assembly redirection if you’re in control of the version that loads, but that can get complicated too.

Unfortunately, since the change between versions is “breaking,” there’s no direct fix without either a different version of your app or a code tweak like reflection.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: ZihamZuhair