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 encountered this when I renamed a project (and the assembly name), which was depended upon by an ASP.NET project. Types in the web project implemented interfaces in the dependent assembly. Despite executing Clean Solution from the Build menu, the assembly with the previous name remained in the
bin
folder, and when my web project executedthe above exception was thrown, complaining that interface methods in the implementing web types were not actually implemented. Manually deleting the assembly in the web project's
bin
folder resolved the problem.This error can also be caused if an assembly is loaded using Assembly.LoadFrom(String) and is referencing an assembly that was already loaded using Assembly.Load(Byte[]).
For instance you have embedded the main application's referenced assemblies as resources but your app loads plug-ins from a specific folder.
Instead of using LoadFrom you should use Load. The following code will do the job:
I faced almost same issue. I was scratching my head what is causing this error. I cross checked, all the methods were implemented.
On Googling I got this link among other. Based on @Paul McLink comment, This two steps resolved the issue.
and the error gone.
Restart VS Plugin
Thanks Paul :)
Hope this helps someone who come across this error :)
In my case it helped to reset the WinForms Toolbox.
I got the exception when opening a
Form
in the designer; however, compiling and running the code was possible and the code behaved as expected. The exception occurred in a localUserControl
implementing an interface from one of my referenced libraries. The error emerged after this library was updated.This
UserControl
was listed in the WinForms Toolbox. Probably Visual Studio kept a reference on an outdated version of the library or was caching an outdated version somewhere.Here is how I recovered from this situation:
Reset Toolbox
in the context menu. (This removes custom items from the Toolbox).In my case the Toolbox items were restored to their default state; however, the Pointer-arrow was missing in the Toolbox.
In my case Visual Studio terminated with a violation exception and aborted.
Now everything is running smoothly.
As an addendum: this can also occur if you update a nuget package that was used to generate a fakes assembly. Say you install V1.0 of a nuget package and create a fakes assembly "fakeLibrary.1.0.0.0.Fakes". Next, you update to the newest version of the nuget package, say v1.1 which added a new method to an interface. The Fakes library is still looking for v1.0 of the library. Simply remove the fake assembly and regenerate it. If that was the issue, this will probably fix it.
I came across the same message and here is what we have found: We use third party dlls in our project. After a new release of those was out we changed our project to point to the new set of dlls and compiled successfully.
The exception was thrown when I tried to instatiate one of the their interfaced classes during run time. We made sure that all the other references were up to date, but still no luck. We needed a while to spot (using the Object Browser) that the return type of the method in the error message was a completely new type from a new, unreferenced assembly.
We added a reference to the assembly and the error disappeared.