.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

Visual C++ 6.0: Don't Let Memory Allocation Failures Crash Your Legacy STL Application

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Most C++ developers make extensive use of the Standard Template Library (STL) in their code. If you are one of them and are using STL and Visual C++ 6.0 directly out of the box, your application is at high risk of crashing under low memory conditions. The problem arises because checking for failure of operator new is such an uncommon practice. To make things worse, when new does fail, the response is not standard. Some language compilers return NULL while others throw an exception.In addition, if you are using STL in an MFC project, be aware that MFC has its own set of rules. This article discusses these problems, explains how the default behavior has changed in Visual C++ .NET 2003, and outlines the changes you must make if you're using Visual C++ 6.0 so that you can safely use the STL when operator new fails.

James Hebben

MSDN Magazine September 2003

View Complete Post

More Related Resource Links

Integrating a Legacy Web Application in SharePoint

This month we will continue with the theme of deploying Microsoft's SharePoint as a company intranet by describing a method for integrating a legacy Web application inside a SharePoint site.

In many companies the intranet site is not just a home page with announcements. It houses Web applications used by many different departments. In last month's article, I built a page to search the employee table in Northwind (the sample database included in Microsoft's SQL Server). This month, I will move the Web pages used to add/remove records from the table into the SharePoint intranet.

Integrating a Legacy Web Application in SharePoint

This month we will continue with the theme of deploying Microsoft's SharePoint as a company intranet by describing a method for integrating a legacy Web application inside a SharePoint site.

How to detect and avoid memory and resources leaks in .NET application

Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

Visual Studio 2008 Memory problems


My memory in task manager reaches about 900,000K  and I don't know why it does this. Definately slows everything down, especially when I rebuild my tableAdapters, takes about 30 seconds sometimes to rebuild the project.

Error while setting up application on Win7 using Visual Studio.NET 2003


Hi All,

Getting the below error while setting up application on Win 7 using visual studio.NET 2003.


cannot find the components for communiacting with the front page server extensions...


I understand by the error, i need to install Front page server extension, but not able to figure how to install using IIS 7.5.

I had XP machine with IIS 5.1, able to find the option.


Need your help in resolving this.




Performance: Find Application Bottlenecks with Visual Studio Profiler


We will introduce you to the Visual Studio Profiler by walking through a sample performance investigation, pinpointing code inefficiencies in some sample applications.

Hari Pulapaka and Boris Vidolov

MSDN Magazine March 2008

Crystal Reports: Add Professional Quality Reports to Your Application with Visual Studio .NET


Crystal Reports for Visual Studio .NET provides a comprehensive reporting solution for .NET developers that is thoroughly integrated with both the Visual Studio .NET IDE and the .NET Framework. Crystal Reports supports ADO.NET, XML Web Services, and ASP.NET server controls and caching. It also integrates seamlessly with the Visual Studio .NET Server Explorer, toolbox, and design environment. It has a rich programming model and flexible options for customizing and deploying reports. These major features and others covered here take the drudge work out of data representation in your own applications.

Andrew Brust

MSDN Magazine May 2002

Tip #107 Did you know . How to improve debugging performance for MVC2 application in Visual Studio 2

VS2010 Ultimate included IntelliTrace functionality by default.  IntelliTrace captures events (e.g. exceptions), and can affect performance of debugging. The typical performance hit is about 5% in the default mode (collection can be increased to...(read more)

IIS Crash with Faulting application w3wp.exe, faulting module mscorwks.dll, version 2.0.50727.42

The scenario is that, a .Net Webservice is making calls to C++ DLL (made from VC6 studio) This app works perfectly well for sometimes or over a period or for a high volume of hits and suddenly you see IIS crash along with service crash with the following error "Faulting application w3wp.exe, faulting module mscorwks.dll, version 2.0.50727.42" There is no pattern for this problem. The work around is to restart the IIS.    Can anybody tell me what could be the issue here?

Posting data to a website (HTTPS) from a Desktop Application in Visual Basic (.Net 3.5 or .Net 4.0)

Hello everyone, I'm trying to create a desktop application that will update my IPv4 address to an IPv6 Tunnel broker.  I have the app running up to the point where it sends the data to the website, and then I get exceptions.  I'd like someone to take a look at my code, and tell me what I've got wrong (if anything).  Here's the code that I have (the only portion that is filled in is for Hurricane Electric) Dim strUsername As String = txtUsername.Text.ToString 'User Id supplied by the User. Dim strPassword As String = txtPassword.Text.ToString 'Password supplied by the User. Dim strPasswordHash As String = "" ' this will be created from the hashing of the password supplied by the user. Dim strTunnelID As String = txtGlobalTunnelId.Text.ToString 'Global Tunnel ID (He.net and ) Dim strUrl As String = "" ' Place holder for the URL Which will be provided after the password is hashed and specified by the tunnel broker. Dim strTunnelBroker As String = cbxTunnelBroker.SelectedItem 'Sets the Tunnel Broker to the user specified one. Dim wc As New WebClient() 'Allows for posting data to the server 'holds the server response. Dim strData As String = "" 'Provides the data for the form. Dim result As String = "" Select Case strTunnelBroker Case

Sporadic .NET application crash with "Fatal Execution Engine Error"

I have a .NET application that runs for several hours.  It is a multi-threaded app that does some calculations and saves the results to the database.   On one machine in particular, it has been crashing recently with the following exception recorded in the Event Log: .NET Runtime version 2.0.50727.4206 - Fatal Execution Engine Error (6C9D7B6E) (80131506) Faulting application AnalyzerConsole.exe, version, time stamp 0x4c76d28b, faulting module mscorwks.dll, version 2.0.50727.4206, time stamp 0x4bf4c6a7, exception code 0xc0000005, fault offset 0x0011627d, process id 0x%9, application start time 0x%10. Sometimes it runs for hours without crashing, but usually it will crash eventually. I have captured a dump, and this is the call stack: > ntdll.dll!_DbgBreakPoint@0()   mscorwks.dll!WatsonLastChance()  + 0x133 bytes   mscorwks.dll!EEPolicy::LogFatalError()  + 0x23c bytes   mscorwks.dll!EEPolicy::HandleFatalError()  + 0x47 bytes   mscorwks.dll!CLRVectoredExceptionHandlerPhase3()  + 0x10dae2 bytes   mscorwks.dll!CLRVectoredExceptionHandlerPhase2()  + 0x20 bytes   mscorwks.dll!CLRVectoredExceptionHandler()  + 0xb7 bytes   mscorwks.dll!CPFH_RealFirstPassHandler()  + 0x8ac bytes   mscorwks.dll!_COMPlusFrameHandler()  + 0xb9 bytes   ntdll.d

Visual Studio asp C#.NEt web application publishing tweet/status on Twitter/Facebook

Hi guysIf you could give me some guidelines It would mean a lot to me. what type of authentication I use, how to do  id from localhost, how to modify web.config file etc 

BUG: Exceptions propagation behaviour is different if the application is run inside visual studio.

I'm going crazy. I have a simple application: one form, one module. The project is configured to start from sub main. The module contains: Module Module1 Public Sub main() Try Application.Run(New Form1) Catch ex As Exception MessageBox.Show(ex.Message, "Fatal Error") End Try End Sub End Module Form1 contains one button and one event: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Throw New Exception("operation aborted") End Sub End Class I run the application inside visual studio... A new instance of Form1 is shown. I click the button. The exception is propagated to the sub main and the messagebox is shown. RIGHT!... I close visual studio (without recompiling anything) and I run the SAME .exe that was generated before... A new instance of Form1 is shown. I click the button. The exception IS NOT propagated to the main sub and a dialog appears: System.Exception: operation aborted in textexception.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Lino Barreca\Documenti\Visual Studio 2008\Projects\textexception\textexception\Form1.vb:riga 4 in System.Windows.Forms.Control.OnClick(EventArgs e) in System.Windows.Forms.Button.OnClick(EventArgs e) in System.Windows.Forms.ButtonBase.OnKeyUp(KeyEventArgs kevent)

Strange lockup in multithreaded application - Visual Studio debugger unable to break execution

Multithreaded C# application, Visual Studio 2008, Windows XP, Framework 3.5 SP1. This application is a little crawling utility to download pages from our website, extract some information and upload it into a database. It runs for a while, then somewhere between about 10 minutes and an hour in, it locks up totally, user interface and all. When I try to "break all" in the VS debugger, I get a message "cannot break execution". Now the confusing thing about this is that since the UI was locking up, I thought that some deadlock must be happening on the main UI thread. So I started stripping out any code and locks that were being acquired on that thread that might cause problems ... until there was nothing left. Even with the window simply spawning a bunch of worker threads on create, then totally forgetting about them and giving no reverse access, the lockup still happens, the UI still freezes and VS still can't break the execution.   There are 10 threads to do the crawling, and one each to do the processing and the uploading. The next thing I did was take out the uploading entirely to remove the possiblity of a deadlock in the SqlClient libraries. No difference. So now, the only things that could be really deadlocking the main thread that I can see are the centrally created HTTPWebRequest objects I'm using. WebRequest.create is supposedly thread safe

Accessing memory of a remote process (x64) from application (x86) - and the other way

Hi everyone, My program access a remote process, e.g. to get the text of ListViewItem. It uses ReadProcessMemory, WriteProcessMemory, SendMessage, LV_ITEM via PInvoke. Below is a little codesnippet. This doesnt work, when i compile for x86 and the remote process is x64 (or the other way). I know that is because the size of IntPtr - and so of the LV_ITEM-Structure - is different. Is there any way, to access x86 and x64 remote processes from the same application?  Is there any way to find out if the remote process is x86 or x64 and make my call's with a suitable LV-Item Structure? thanks Torsten Codesnippet: LV_ITEM lvitem = new LV_ITEM(); // Allocate memory in the remote process's address space string s = string.Empty; IntPtr pszTextMemory = VirtualAllocEx(hProcess,IntPtr.Zero,  1024, (int)(AllocationType.MEM_RESERVE|AllocationType.MEM_COMMIT), (int)(AccessProtectionType.PAGE_READWRITE)); lvitem.pszText = pszTextMemory; ... IntPtr pLVItemMemory = VirtualAllocEx(hProcess, IntPtr.Zero,  Marshal.SizeOf(lvitem), (int)(AllocationType.MEM_RESERVE|AllocationType.MEM_COMMIT), (int)(AccessProtectionType.PAGE_READWRITE)); IntPtr lvItemPtr = Marshal.AllocHGlobal(Marshal.SizeOf(lvitem)); Marshal.StructureToPtr(lvitem,lvItemPtr,false); WriteProcessMemory(hProcess, pLVItemMemory, ref lvitem, Marshal.SizeOf(lvitem), ref written); SendMessage(hListView, LVM_GETITEM

SQL 2008 memory allocation

Hey everyone, I have a new server running SQL 2008 with 2.5 GB RAM and noticed all the available memory was being allocated.  In task manager SQL was not taking up much memory, but once the service was stopped, my available memory nearly tripled.  I was not aware there is a max memory setting in SQL configuration.  This is probably the cause of my memory leak?  What do you suggest I change this max setting to?
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