I've got a very weird bug on our test machine. The error is:
System.TypeLoadException: Method 'SetShort' in type 'DummyItem' from assembly 'ActiveViewers (...)' does not have an implementation.
I just can't understand why. SetShort
is there in the DummyItem
class, and I've even recompiled a version with writes to the event log just to make sure that it's not a deployment/versioning issue. The weird thing is that the calling code doesn't even call the SetShort
method.
I got this when my application didn't have a reference to another assembly defining a class that the method in the error message used. Running PEVerify gave more helpful error: "The system cannot find the file specified."
I received this error after a recent windows update. I had a service class set to inherit from an interface. The interface contained a signature that returned a ValueTuple, a fairly new feature in C#.
All I can guess is that the windows update installed a new one, but even explicitly referencing it, updating binding redirects, etc...The end result was just changing the signature of the method to something "standard" I guess you could say.
The other time you can get this error is if you have an incorrect version of a signed assembly. It's not the normal symptom for this cause, but here was the scenario where I got it
an asp.net project contains assembly A and assembly B, B is strongly named
assembly A uses Activator.CreateInstance to load assembly C (i.e. there is no reference to C which is built separately)
C was built referencing an older version of assembly B than is currently present
hope that helps someone - it took me ages to figure this out.
FWIW, I got this when there was a config file that redirected to a non-existent version of a referenced assembly. Fusion logs for the win!
I keep coming back to this... Many of the answers here do a great job of explaining what the problem is but not how to fix it.
The solution to this is to manually delete the bin files in your projects published directory. It will clean up all the references and force the project to use the latest DLLs.
I don't suggest using the publish tools Delete function because this tends to throw off IIS.
This simply means that the implementation project is out of date in my cases. The DLL containing the interface was rebuilt but the implementation dll was stale.