Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MissingMethodException - "ctor" method not found

We are getting intermittent problems on a production server that we cannot recreate.

There are two very strange things about the issue. Firstly it's a method not found error on the constructor (ctor) for an exception handling helper class and secondly we have custom errors switched on for remote users and this property is being ignored.

The detail of the error is:

Server Error in '/MyWebsite' Application.


Method not found: 'Void MyExceptionHelperClass..ctor (System.Exception)'.

...
Exception Details: System.MissingMethodException: Method not found: 'Void MyExceptionHelperClass..ctor (System.Exception)'.
...

The stack trace is pretty unhelpful.

My thoughts are that there may be an out-of-memory error or something like that that is killing the page. When the exception handling code kicks in it tries to create an exception object which fails for the same reason giving this error.

However this is wild speculation. We are waiting for the event logs to see whether anything is amiss with the server but in the meantime does anyone have any thoughts or suggestions?

UPDATE:

It has proven difficult to get information out of the team responsible for the production servers but I have managed to find out that as far as load balancing is concerned, this site is currently only running on one server (this can be made to switch over onto another if necessary). Given that this is an intermittent problem and there is only one server involved, then I find it difficult to believe that this could be an assembly issue. Surely if it was then the problem would occur every time?

like image 422
Chris Simpson Avatar asked Jun 09 '09 18:06

Chris Simpson


4 Answers

If you see this error happening on a site that has custom errors turned on, then the error is happening in the custom error handling routine itself.

From the look of the .NET error message it appears that your routine is expecting a constructor that accepts an exception by reference - your comment above shows a constructor that accepts by value.

Check carefully that there isn't a stale version of an assembly in your system somewhere. These can lurk in the Temporary ASP.NET Files folder; you'll need to do an "iisreset /stop" before you can clear them out.

In that regard it's always a good idea to make sure that AssemblyInfo.cs is set up to automatically stamp version numbers in some way. We have our version numbers tied to our source code repository system and CI build box so we can tell exactly what was in what assembly really easily.

like image 118
Jeremy McGee Avatar answered Nov 19 '22 20:11

Jeremy McGee


I would use elmah: http://code.google.com/p/elmah/ to hopefully give you a bit more insight into the issue. It is free and can be used on an existing site without any recompilation. Try it - and post back if the issue is still happening.

like image 43
rifferte Avatar answered Nov 19 '22 21:11

rifferte


As others have also mentioned, I would suspect that your site is somehow using an out of date version of an assembly. Something you could try doing is a full Precompile of your site before deploying to your production server. This ensures that ASP .Net doesn't dynamically compile the site on the fly, and therefore should mean that it's using completely up to date code throughout.

like image 33
tbreffni Avatar answered Nov 19 '22 21:11

tbreffni


Do you have a no parameter public constructor defined for MyExceptionHelperClass in your code? Or is the class meant to only have static methods, in which case it should be a static class.

public class MyExceptionHelperClass()
{
   public MyExceptionHelperClass() { }
}
like image 37
jjxtra Avatar answered Nov 19 '22 22:11

jjxtra