.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

WPF textbox throwing OutOfMemory exception...

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :WPF


I am using a texbox in my appication to capture the log. But when I reach a certain point, it throws a system.outofmemory exception and crashes the app. How can I handle such a situation. I really need to show all the contents to the user as I cannot remove older contents. Is it possible that I save some of the older lines to a temp file? If yes, how do I do it and also at the end I should be able to hit a Save Button to Save all the contents to a text file at the specified location. So if I am transfering contents of the textbox to a temp file then how do I combine the whole log (from the temp file as well as the textbox) and save it to this new file? Also is it possible to remove the temp file everytime the OS is restarted?? 

Any help will be greatly appreciated.


View Complete Post

More Related Resource Links

PathGradientBrush throwing OutOfMemory exception

Hi, I don't know why I'm getting an OutOfMemoryException whil trying to create a PathGradientBrush. Here is my code:   Code Block GraphicsPath gp; PathGradientBrush pgb; Rectangle rec;   rec = new Rectangle(new Point(35, 35), new Size(60, 60));   Point[] pontos = new Point[6]; pontos[0] = new Point(rec.Left, rec.Bottom); pontos[1] = new Point(rec.Left, rec.Top - 2); pontos[2] = new Point(rec.Left + 2, rec.Top); pontos[3] = new Point(rec.Right - 2, rec.Top); pontos[4] = new Point(rec.Right, rec.Top + 2); pontos[5] = new Point(rec.Right, rec.Bottom);   byte[] pontosTipo = new byte[6]; pontosTipo[0] = (byte)PathPointType.Start; pontosTipo[1] = (byte)PathPointType.Line; pontosTipo[2] = (byte)PathPointType.Bezier; pontosTipo[3] = (byte)PathPointType.Line; pontosTipo[4] = (byte)PathPointType.Bezier; pontosTipo[5] = (byte)PathPointType.Line;   gp = new GraphicsPath(pontos, pontosTipo); pgb = new PathGradientBrush(gp); // OutOfMemoryException pgb.SurroundColors = new Color[] { Color.White, Color.Blue };     This code was running in the Paint event, and then I passed to the constructor. Still, the out of memory exception keeps throwing. I have no Idea why this is happening. It is an empty form. Any ideas on why this is happening?   Thanks for any help, Regards, Fábio

Error Handling: Throwing Custom Exception Types from a Managed COM+ Server Application


Exception handling semantics in .NET are based on type, so you can create custom exceptions that have their own properties and methods. In .NET, exceptions are first-class citizens, and since they're the built-in error handling mechanism, all .NET-compliant languages must support exceptions. In addition, COM+ services are available to .NET code as Enterprise Services, so you can leverage exceptions in your Enterprise Services design.In this article the author describes custom exceptions, throwing exceptions across COM interop boundaries, and working with Enterprise Services.

Bob DeRemer

MSDN Magazine March 2004

'System OutOfMemory Exception' while using rdlc in Windows application

hi Everyone , I am Using Reporting Service (.rdlc) in my Windows application , i am getting Error System OutOfMemory Exception Like "an error occured during local report processing An Unexpected error occured in Report Processing Exception of type 'System OutOfMemory Exception'Was Thrown " what to do Please anyone help me ... Advance Thanks Anilmarnal

WCF Service stops after throwing a unhandled exception :no user is logged on.

Hi All,       I have written a WCF service which is hosted as a Managed windows service. I consume this service in a web application. The service is built using a httpBasicBinding and security Mode ="none". I'm now getting the following exception, after which the service stops  "An unhandled exception ('System.ComponentModel.Win32Exception') occurred in CMMonitorService.exe [1812]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on." I had tried changing the security mode to Transport/Message. with windows credential then I get a access to the path denied error. Can anyone provide hint on what am I missing and what would be the appropriate security mode and client credential to use along with basichttpBinding?

OutOfMemory Exception on 64 bit machines (Interop Problem)

Hello Our application needs to display the printer settings dialog. This works fine in 32bit windows systems, but results in a System.OutOfMemoryException at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb) when it is running under 64bit (Windows 2008 Server). The problem can easily be reproduced in a winform app. You need to set the platform target to x86 to experience the problem.Unfortuantely, our application needs to be built fox x86 for other reasons. Any ideas why this happens? Kind Regards Mat Source Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication8 {     public partial class Form1 : Form     {         [DllImport("kernel32.dll")]         static extern IntPtr GlobalLock(IntPtr hMem);         [DllImport("kernel32.dll")]         [return: MarshalAs(UnmanagedType.Bool)]         static extern bool GlobalUnlock(IntPtr hMem);         [DllImport("kernel32.dll")]   &n

Enum in WCF is throwing exception

wcf service method is returning a datacontract that contains an enum .The following error is thrown in the clientSystem.ServiceModel.CommunicationException was caught  Message="An error occurred while receiving the HTTP response to http://localhost:8731/Design_Time_Addresses/WCFTest3/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."  Source="mscorlib"  StackTrace:    Server stack trace:        at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)       at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)       at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)       at System.ServiceModel.Channels.ClientReliableChannelBind

WCF: Problem throwing FaultException after touching Exception.Data collection



My client code receives a CommunicationException if my server code touches the Exception.Data collection.  If my server code avoids the Exception.Data collection, then my client code works (i.e. it receives my custom exception as expected). 


I have reduced this problem down to two simple examples (see below)..one that works (A), one that does not (B).  The only difference between the two examples is that in example B, the code looks at the Exception.Data.Count property.


Why would touching the Exception.Data collection cause my client code to receive the CommunicationException? 

Is there any way to avoid this?


Thank you in advance for an consideration you may give to this question. 


A: Working Example: Client Receives CustomException
  throw new CustomException("This is a custom exception.");
 catch (CustomException ex)
  throw new FaultException<CustomException>(ex, new FaultReason(ex.Message), new FaultCode("Receiver"));


B: Non-working Example: Clien

Error System.outofMemory Exception


Dear All,

i want to ask about Analysis service.

i have a web application that display an OLAP Service.. My Analysis service spesification : Windows 2008 Data center R2 64 bit, SQL 2008 R2 memory 8giga.

when i drill down a dimension it shows an error System.OutOfMemory.Exception.. Actually the memory of my computer still remain 1.5 Giga.. Already use 6,5 giga.


Is there any solution for this Error ?


Aditya Christian

issues with Microsoft.Office.Interop.Excel in asp.net throwing Exception from HRESULT: 0x800A03EC


i m using Microsoft.Office.Interop.Excel in asp.net for Excel file as anEmail attachment .

i get the data and write to Excel but when i try to save like:

oWB.SaveAs(strCurrentDir +strFile, Microsoft.Office.Interop.Excel.


XlFileFormat.xlWorkbookNormal, null,

WorkflowRuntime.CreateWorkflow => Throwing Exception

 I am getting following exception from WorkfolwRuntime ..........
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Workflow.Runtime.TrackingListenerFactory.WorkflowExecutorInitializing(Object sender, WorkflowExecutorInitializingEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at System.Workflow.Runtime.WorkflowRuntime.WorkflowExecutorCreated(WorkflowExecutor workflowExecutor, Boolean loaded)
   at System.Workflow.Runtime.WorkflowExecutor.RegisterWithRuntime(WorkflowRuntime workflowRuntime)
   at System.Workflow.Runtime.WorkflowRuntime.RegisterExecutor(Boolean isActivation, WorkflowExecutor executor)
   at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
   at System.Workflow.Runtime.WorkflowRuntime.GetWorkflowExecutor(Guid instanceId, CreationContext context)
   at System.Workflow.Runtime.WorkflowRuntime.Intern

Infopath System.OutOfMemory Exception when try to upload larger files


I am getting “System.outOfMemory” exception when we are trying to upload 40 MB file into InfoPath Browser Form. I have already tried following methods but of no use. Any recommendation to fix the issue??


1.       Have increased upload limits for Web Application level

2.       Have increased Connection time out in IIS


Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.


Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend