Thursday, May 22, 2008

Error - GetTypeHashCode() : no suitable method found to override

I usefully hijacked this from: http://blog.stackley.net/article.php?story=20070117165732356

I found it very useful so I want to propagate it. I found a need for it while transferring my site from vb.net to C#.


After creating an ASP.NET web form using Microsoft Visual Studio 2005 Team Suite, I renamed the form from it's default name "Default.aspx" to a more user-friendly name "Order.aspx" within MS VS. After adding more code to the C# code-behind page, I discovered the following line: "public partial class _Default"

Being new to the ASP.NET programming language, I changed the "_Default" to "Order" thinking MS VS had failed to rename items within the code it generates. This caused the following error to display at debug/run time: "GetTypeHashCode() : no suitable method found to override"

There were several other errors displayed as well.

The class names must match between the .aspx and .aspx.cs web pages. Here is what the lines in each file should look like:

In the ASPX source file: %@ Page Language="C#" codefile="FormName.aspx.cs" Inherits="FormName_aspx" %

In the ASPX.CS source file: public partial class FormName_aspx : Page

Once I changed the .ASPX file to match the class name in the .ASPX.CS file, the errors were resolved.

25 comments:

Anonymous said...

I had a similar problem, and this has proven very helpful. Thankyou.

Anonymous said...

Thank you, this post helped me to fix the error, i just replaced the .cs file with another .cs ...

Anonymous said...

Bless Technage and Google. I could have been hours trying to sort this out from the manual and help system. Many many thanks.

Anonymous said...

Thank you so much. I did the same renaming thing and didn't think to check to make sure that VS2005 did proper renaming. Microsoft FTW.

Kudos

tup said...

this helped me too, I had forgot to change one character...

Anonymous said...

The problem occurs too, if you do not inherit your partial class from System.Web.UI.Page or a derived class.

The problem appeared to me, when I removed a speciall base class and forgot to put in a simpler one.

Thx, anyhow - your article brought me to look closer to the class.

Anonymous said...

Thanks, this tip helped a lot

Anonymous said...

marvellous itried to solve the problem for 2-3 hrs
thnx alot

Anonymous said...

It was really help full for me; Three days I Googled but this article took 15 minutes !

Saurabh
Bangalore

Anonymous said...

Thanks a lot!!! It solved my problem!!! I've been thinking so long on this error... @.@
Good job!

Anonymous said...

Thank you very much for this straight to the point solution that actually worked:D

Anonymous said...

woo-hoo!!!

Thanks...thah solved the problem.

Anonymous said...

thank you.. :)

Pardeep said...

Thanks buddy

Anonymous said...

hey buddy thnx ..................
It helps me a lot
........................

Anonymous said...

It was also the case that I was on a System.Web.UI.Page class type and extending a class that was System.Web.UI.UserControl. make sure the class inheritance is correct. Also thanks.

Anonymous said...

Thanks

Anonymous said...

thank you

Anonymous said...

thanx sir...............

Anonymous said...

it's help me

Islam FAQ said...

In my case, this was a real bummer.
All was fine and then boom, it just started throwing errors. Apparently, a different aspx file was referencing my .cs file and since the class names did not match, it was messing up.

Trust me, took me more than an hour to discover the error.

Anonymous said...

Thanks.... this really helped me

Anonymous said...

Thanks Yar Thank u very much

Anonymous said...

thANKU !!!!this really worked

sreeja said...

THANK YOU VERY MUCH...