ADO.NET :: Web Application Throws An Exception Now And Then?
Jan 17, 2011
every now and then my server throws an exceeption. When it first starts to throw an exception the server wont work until I reinstall my web app (copy and Paste). I think this forces a restart of IIS and somethiong gets cleared bercause the app is working again for some hours, sometime less. Now I have created a scheduled task recopying all the web site files every 15 minutes. This restarts the server and the users are able to use the site. Problem is that now the server either start throwing exceptions, or the user is kicked because the server restarts. So you see, this is absolutly not a good solution.I have looked in the Event Viewer on the sever. Her is some examples of the exceptions:
[Code]....
An other exception:
[Code]....
As you can see, the common part of all the exceptions is the Exception message: Unable to cast object of type 'System.Int32' to type 'System.String'. Her is the code of one of the places throwing an exxception:
I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I required to add new console application to the existing solution in which I call data layer methods for retrieving data from DB but I get an exception "The type initializer for threw an exception."When I debugged I found that the exception is thrown at datalayer on first line of class where I get connectionstring from
web.config, the code is public static readonly string CONNECT_STRING =
Now if I hardcode the connection string value like public static readonly string CONNECT_STRING = "Data Source=XYZ;uid=sa;password=XXX;initial catalog=ABC;"
it works fine.I don't understand what is the issue here as web application works fine with this datalayer.
We have an old asp application that instantiates a .NET com visible class. In this class, we do some serialization to store our object in the session.
When I call the following line of code in my test class, it works fine.
var cereal = new XmlSerializer(couponApplicator.GetType());
However, when it gets called in the website and I am debugging, it throws the following error:
{"Cannot execute a program. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\WINDOWS\TEMP\rwot-yx9.cmdline"."} System.SystemException {System.Runtime.InteropServices.ExternalException}
I thought maybe it was permissions related so I tried giving 'EVERYONE' full control to the windows/microsoft.net folder as well as the windows/temp folder. For reference, I am running this on a Windows XP machine.
in my masterpage of my asp.net mvc 2 app. This method returns the version of the application.
i also have this code in my controller:
class GenericController : BaseController { [ChildActionOnly] public string Version() { try { string assemblyFile = Assembly.GetCallingAssembly().FullName; FileInfo fi = new FileInfo(assemblyFile); string version = fi.LastWriteTime.Year.ToString( ) + fi.LastWriteTime.Month.ToString() + fi.LastWriteTime.Day.ToString(); return version; } catch (Exception e) { return "1.0"; } } }
Now i get this error: Execution of the child request failed. Please examine the InnerException for more information.
and the innerexcpetion is: {"The controller for path '/Account/LogOn' was not found or does not implement IController."}
What i was thinking is that maybe the code can't execute because the user is not logged on yet, and tries to redirect to the logon method etc.
So the first thing i was thinking is to grant access in the web.config (like i do with the directory that has the css and images in it, it should also be accessable when you're not logged on:
I have a custom authorization attribute, that basically check if the current user's role is equals to the current area name, and if not, redirect them to the signup view in that requested area. (dummy role provider at this this stage, therefor check it against the user's name at the moment)
It runs fine (IIS) but when I debug it I can see a Security Exception are being thrown by the code
I have several text boxes in an asp:Panel. When the user hits Enter from any of those boxes, I want the form to submit as if they've clicked btnAddTag. (When the cursor is not in those boxes, I have a different default submit button.)
I am using Membership.DeleteUser("username",true) method to delete the user from DataBase. This works fine in my local machine. When i publish the same code, i am not able to delete the user..... it throws an javascript error saying..... "Login failed for user NT AUTHORITY/NETWORK SERVICE"
I have a date field in a typed dataset that created from database.
I get an NULL Value exception when I try to enter some null value. I am not able to set the Nullvalue property of the DateTime field in XSD to other value other than Throw Exception.
The following code listed on the bottom is a dropdown extender contained with a listview insert template. The code works fine however int VS 2008 Debug mode, its throwing the exception:Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.If I click ignore or continue, the taret label is properly populated with the appropriate value. Has anybody encountered this and is
In Asp.net application. i cache a Linq to Xml result to a Cache object. when i cast the cache object back to generic list. i get the following exception.
[A]System.Collections.Generic.List`1[CarRentalAddress] cannot be cast to [B]System.Collections.Generic.List`1[CarRentalAddress]. Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'. Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'.
My code looks like this.
if (!Page.IsPostBack) { if (Cache["xml"] == null) { DataSet ds = new DataSet(); ds.ReadXml(HttpContext.Current.Server.MapPath("~/CarRentalAddress.xml")); var grid = (from d in ds.Tables[0].AsEnumerable() orderby d.Field<string>("City") where d.Field<string>("Enabled") == "1" select new CarRentalAddress { City = d.Field<string>("City"), HotelName = d.Field<string>("HotelName"), Address = d.Field<string>("Address"), EmailID1 = d.Field<string>("EmailID1"), EmailID2 = d.Field<string>("EmailID2") }).ToList(); Cache["xml"] = grid; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } else { //Exception is thrown by this line var grid = (List<CarRentalAddress>)Cache["xml"]; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } }
This problem is trivial to duplicate. Do any query on a table which contains a timestamp / rowversion column. Set a breakpoint and examine the resulting query in the Linq to SQL visualizer. Click on Execute which displays the results in a DataGridView. For each row you get "System Argument Exception: Parameter is not valid" when it tries to display the timestamp / rowversion in the grid. What is most annoying is that there is no way to get out of the visualizer without going to Task Manager and killing the Visual Studio process, devenv.exe.
This is definitely a bug. How can you presume to be able to display a database query when you can't display an essential datatype like timestamp / rowversion? Is there any way around this ? I would like to add that in general the CLR is woefully inadequate in the way it handles timestamp / rowversion fields. It would be nice if they could be defined, copied, compared, displayed and serialized in some standardized automatic way.
AjaxControlToolkit.ToolKitScriptManager.OnInit() throws thread abort exception for every aspx page. I have an asp.net 2.0 Ajax application, where I have set the following properties of ToolScriptManager on my pages.
I have this configuration on all the aspx pages in my application. When I checked the .NET CLR exception Performance counter I figured out a large number of exceptions, mainly one exception per page load is occuring. On running windbg I was noticed that
AjaxControlToolkit.ToolKitScriptManager.OnInit() has the following code block which is getting executed. The OutputCombinedScriptFile() returns true. But since I am setting my controls on DesignTime still designmode is set to false for toolkitscriptmanager.
if (!DesignMode && (null != Context) && OutputCombinedScriptFile(Context)) { // This was a combined script request that was satisfied; end all processing now Page.Response.End(); }
I am not sure if this is a reported bug or even a bug with ajax, but this is causing havoc in my load test results as I have around 3 hundred thousand HTTP requests to be handled per day out of which 80% are aspx page requests resulting in a large number of threadafbortexceptions, thus affecting the performance.
How to track the exception in application. means let say there is enterprise project, If we deliver the project to end user (forget for a while any tester is there/ or in my side who can track this exception). and while navigating or doing any operation , a custom error page occurs, which is define by developer from his web.config file.
then how user will let know to developer that he get something exception while doing particular operation ? How developer can tack this exception without having any kind of debugging. Let say user not allow to deploy again. developer want to track this exception on deployed application. What he must to do. I know we can put try..Catch but need to now particulars..
I've created an asp.net application, and most of my code that does something with the database throws ApplicationExceptions if you try to do something that I don't want you to. The problem is that, as is my understanding, Exceptions should only be used for truly unexpected events, not for validation/verification; however much of the validation/verification logic in my application simply can only be done in code, as opposed to with validation controls etc.
Can anyone point me in the right direction? One is apparently not really supposed to throw exceptions for validation reasons, but I can't figure out a better way of saying "NO" to the page and escaping the function, when criteria for, for example, inserting a row are not fulfilled.
I have a web application and when I decided to test on IIS 7 i have this Exception when trying to load a couple of pages that uses Entity Framework 4. I use EF 4 with my own CRUD assemblies but sometimes using the EntityDataSource. I have noticed that the problem is not appearing in all my Web Pages but I think in those that I use the EntityDataSource.
Here's the log from a Page:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeModule.GetTypes() at System.Reflection.Assembly.GetTypes() at System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly() at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors) at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) at System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) at System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage) at System.Data.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action`1 logLoadMessage) at System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() at System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.FormView.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at System.Web.UI.WebControls.FormView.EnsureDataBound() at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I think its the EDM problem but I can't get through. I should mention that in my development pc is working all perfectly!!!
My controls are DevExpress but I dont think this should play any role!
[EDIT]
Forgot to mention that I use Self tracking Template with the Entities.tt in a separate assembly!
[EDIT 2]
On my local Windows 7 IIS works OK! It's Windows Server 2008 I can't get it done!
My company has an application that handles shopping cart check out processes.The application is written in VB.net with the .NET 2.0 Framework.We are running IIS 6.0 as the web server and have,what we consider,excellent exception handling.For those exceptions that we can't figure out why they're happening,we use Elmah to handle them,package them up,and email them to us.We still see a fair amount of unhandled exceptions,handled by Elmah.
My question is:This is an application that is used by many people on the web at the same time.If there is an unhandled exception (handled by Elmah, mind you),does this then reset the application so that all users who aren't doing anything naughty see the application blow up in front of them when this happens?
In our Application_Start event handler we're performing some actions that intermittently fail due to file locking issues. In this scenario we would like to return the application to an "un-started" state.By this I mean that the user will be shown an error page, and then the next time a user hits the site the Application_Start event will be fired again.
First of all, quickly what exactly I want to achieve: translate particular exception into the HTTP 404 so the ASP.NET can handle it further. I am handling exceptions in the ASP.NET (MVC2) this way:
protected void Application_Error(object sender, EventArgs e) { var err = Server.GetLastError(); if (err == null) return; err = err.GetBaseException(); var noObject = err as ObjectNotFoundException; if (noObject != null) HandleObjectNotFound(); var handled = noObject != null; if (!handled) Logger.Fatal("Unhandled exception has occured in application.", err); } private void HandleObjectNotFound() { Server.ClearError(); Response.Clear(); // new HttpExcepton(404, "Not Found"); // Throw or not to throw? Response.StatusCode = 404; Response.StatusDescription = "Not Found"; Response.StatusDescription = "Not Found"; Response.Write("The whole HTML body explaining whata 404 is??"); }
The problem is that I cannot configure default customErrors to work with it. When it is on then it never redirects to the page specified in customErrors: <error statusCode="404" redirect="404.html"/>. I also tried to raise new HttpExcepton(404, "Not Found") from the handler but then the response code is 200 which I don't understand why. So the questions are:
1-What is the proper way of translating AnException into HTTP 404 response? 2- How does customErrors section work when handling exceptions in Application_Error? 3- Why throwing HttpException(404) renders (blank) page with success (200) status?
an unhandled win32 exception occurred in w3wp.exe error occures when we run .Net application from IIS. My configuration is Windows server 2008, IIS7, .Net 2.0, and Oracle 10g.