The World’s Leading Microsoft .NET Magazine
   
 
timstall

Donate Today!

Search Box

 

Calendar

««Sep 2008»»
SMTWTFS
 
1
2
3
456
78910111213
14151617181920
21222324252627
282930

My RSS Feeds








Mailing List

Most Popular Tags

                                                           

System.Web.HttpException: External component has thrown an exception

posted Monday, 11 July 2005

As far as debugging difficulty goes, anything that you can reproduce and step through with the debugger is likely simple. Sometimes you'll get an error that occurs before the codebehind is even hit, and you therefore can't debug it like "normal". One such error is: "System.Web.HttpException: External component has thrown an exception."

Web pages integrate both the aspx and codebehind pages. What may be happening is that some control in the html of the aspx page has an onserver attribute that references a non-existent server event. For example, you may have copied from a similar page that had a LinkButton with attribute onserverclick="AddLink_Click". The WebForm expects an "AddLink_Click" method in the codebehind. The original page may have had this method, but perhaps the target page does not. Therefore when you try to load the page, it can't "merge" the aspx and codebehind correctly and therefore crashes before even going to a breakpoint in the CodeBehind's Page_Load.

The solution (in this case) is to ensure that any attributes set in the aspx page are consistent with the codebehind.

links: digg this    technorati    




1. Errol left...
Saturday, 3 September 2005 2:07 am

When next in Australia, IOU one beer! I thought I had kept track of the inconsistency, but your article made me double check. Cheers.


2. Travis Whidden left...
Saturday, 24 September 2005 12:44 pm

stuff like this is always helpful. Thanks for the lead.


3. Ajay left...
Friday, 14 October 2005 1:10 am

If you are sure that the program is fine then there could be one reason to this problem. You should check if the assemblies loaded in w3wp process are loaded from correct locations or not? It can happen that the assembly containing the code is loaded from wrong location. This can be checked by a tool called "listdlls".


4. Ashok left...
Tuesday, 14 February 2006 4:23 am

I hate the sentence 'System.Web.HttpException'. This article moves on diff ways.


5. vijay left...
Thursday, 16 February 2006 6:12 am

Control 'dgrdItemDetails__ctl2_chkDelete_Header' of type 'CheckBox' must be placed inside a form tag with runat=server.


6. europaulo left...
Saturday, 25 February 2006 4:22 pm

Thanks for the hint mate. You helped me big time!


7. Ronny left...
Tuesday, 18 April 2006 6:26 am

I also had this error and nothing worked. I removed code and html, still same error appeared. The fix was remove all temorary files under the framework for this application. This may not be simple, as in typical windows fashion it says it is in use. Delete the directory in command prompt with explorer task termintaed. Not saying it will work for everybody, but I know how frustrating it is when nothing works and this is always something to try.


8. Graeme left...
Sunday, 7 May 2006 5:31 pm

Cheers Ronny, I had this problem and that worked out for me. Rather than massacring the explorer task you can just kill the asp.net worker process and then remove the files.


9. Dom left...
Tuesday, 15 August 2006 12:50 pm

<tr> <td><%# DataBinder.Eval(Container.vReport, "Name") %></td> </tr>

Having this error on this line I have verified vReprot exists in the database, Name is one of the field of the vReport Table. So I am thinking that there is may be a Namespace missing or something like this?

Thanks, Dom


10. george left...
Tuesday, 14 November 2006 4:10 am

After half an hour of searching the net for a solution I thought I could just restart my pc. Yes that worked for me....


11. Michael left...
Tuesday, 16 January 2007 11:23 am :: http://www.wassupy.com

Saved me a boatload of time. Thanks!


12. Brent left...
Thursday, 25 January 2007 6:53 pm

Your comment continues to help people.

Thanks


13. Guilherme left...
Monday, 5 March 2007 5:33 pm

Thanks man... good post.


14. Sainey Drammeh left...
Monday, 18 June 2007 8:47 am

Your article is still saving people from a lot of headaches. It just saved me a ton. Thank you very much.


15. Amit left...
Wednesday, 4 July 2007 8:00 am

When ever in Danmark (or Israel), three beers are on me. I had the problem of copying a button statement which calls it's sub through a JS call (don't ask me why - it's from an older code that due to much required test and validation, i didn't want to change). The problem was that the button sub was declared (as it it's normaly is) as Private. So after reading your explenation for the exception, and going through the code again, i found that and changed it to Protected. Thakn again.


16. Russ left...
Tuesday, 29 January 2008 7:26 am

I got this error when I put the master page code-behind in the same namespace as the rest of the project. Don't understand that.


17. sairam left...
Thursday, 31 January 2008 4:33 pm

That was really great find. It helped me when i was facing this error and was clueless. Thanks for that.


18. rtpHarry left...
Thursday, 7 August 2008 10:36 am :: http://www.dbs-uk.co.uk/web/

I have just had a version of this. Tried to compile and got the error "External component has thrown an exception." popping up when i did a build web site. My solution was to copy all the files I had edited recently into a safe directory outside the project. Then delete the files I had backed up. I deleted them through the project explorer within vwd2008 just in case the ide took an extra step of deleting corrupt temporary files. Then I dragged each combo back until the error occurred again. It turned out it was freaking out over an ascx usercontrol. I took the code out of the control and put it back into the page as I wasnt using it anywhere else anyway. I had recently renamed the source files for this control and then just changed the class name at the top. I dont know if that was what had caused the problem or not.