Monday, August 23, 2010

C# tips

get lots of work done saving different copies of my page.

then i make a slight alteration and BOOM!!!!!!

i get this message:

Server Error in '/appName' Application. 

Compilation Error 


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

Line 1:
Line 2: Partial Class secure_Default
Line 3: Inherits System.Web.UI.Page
Line 4: 



for any one who wants to know.......

i sorted this out by changing the two bits of code:


===================================
in the page itself i changed:



to



===================================
and then in the code behind the page i changed the name of the partial class to match it:

Partial Class secure_homeInherits System.Web.UI.PageProtected Page_Load



Guys, whenever this happens, check your other pages. You most likely have a class duplicated somewhere else on your site. Happens all the time when retiring an old page but leaving it on the server. Make sure the class isn't declared in any other page that happens to be on the server - confuses the compiler since it doesn't know which one to use.

Pays to keep your site clean and tidy. I have spent many painful hours poring over these issues just to find out I didn't remove an obsolete page with the same class name in it.



May be a good idea that when you do that, add .Retired to the end of the namespace the old page lives in.

No comments: