lundi 11 septembre 2017

Why does the addition of the virtual keyword solve a TypeLoadException?

Error scenario:

  1. Installed application using the installer.

  2. Made changes to one class Class (in assembly ClassAssembly.dll) that implemented an interface IClass (in assembly InterfaceAssembly.dll)

  3. Interface remained unchanged.

  4. Patched only ClassAssembly.dll into install directory.

Result:

Method 'get_Property' in type 'Class' from assembly 'ClassAssembly, Version=1.1.1.2, Culture=neutral, PublicKeyToken=null' does not have an implementation. where Property was not modified.

As per answer in TypeLoadException says 'no implementation', but it is implemented patching the ClassAssembly.dll along with InterfaceAssembly.dll was the solution.

HOWEVER...

Adding the virtual keyword to Property implemented in Class also resolved the issue.

Why/how does the virtual keyword help in identifying the correct implementation of the getter?





Aucun commentaire:

Enregistrer un commentaire