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

Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

.NET Framework execution was aborted by escalation policy because of out of memory

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :


I have a SQL CLR used to read a XML file, it works fine when the file is smaller, but will give me this error if the file if bigger i.e. more than 10M.

Msg 6532, Level 16, State 49, Line 2

.NET Framework execution was aborted by escalation policy because of out of memory.

System.InvalidOperationException: Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.


at System.Data.SqlServer.Internal.ClrLevelContext.CheckSqlAccessReturnCode(SqlAccessApiReturnCode eRc)

at System.Data.SqlServer.Internal.ClrLevelContext.GetDatabase(SmiEventSink sink, Int32* pcbLen, IntPtr* ppwsName)

at Microsoft.SqlServer.Server.InProcConnection.GetCurrentDatabase(SmiEventSink eventSink)

at System.Data.SqlClient.SqlInternalConnectionSmi.Activate()

at System.Data.SqlClient.SqlConnectionFactory.GetContextConnection(

View Complete Post

More Related Resource Links

SQL Server 2005 SP2 - AppDomain was unloaded by escalation policy. Out of memory while accessing a c


I am posting this in the .NET Framework inside SQL Server forum as I assume the issue is related to CLR / SQL Server.  Please let me know if this is the incorrect forum.

I am receiving the following error in the event log:

AppDomain [DB_NAME].dbo[runtime].5253 was unloaded by escalation policy to ensure the consistency of your application. Out of memory happened while accessing a critical resource. 
System.Threading.ThreadAbortException: Exception of type 'System.Threading.ThreadAbortException' was thrown.

The system that this is occurring on is a Windows Server 2003 R2 SP2 (32 bit), SQL Server 2005 SP2 with 8 GB of RAM:

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

9.00.3042.00	SP2	Standard Edition

The CLR assembly is relatively simple and is referenced by both store procedures as well as by a table trigger (update).  Essentially the CLR assembly instantiates an object (in a referenced webservice on a separate&

Why i am getting error ==> ".NET Framework execution was aborted. The UDP/UDF/UDT did not end thread


Good evening all,

I developed a C# class libray code. Under which i called a third party .asmx web service. I used "CREATE ASSEMBLY" command to register all my custom assembly and needed .net core assemblies. I did register all needed .net dll's. for Ex:-


C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll

I created a procedure and called my class libray methods from SQL analyzer. See Ex:- code below. But when i executed the code method i see the error ".NET Framework execution was aborted. The UDP/UDF/UDT did not end thread affinity.". For testing purpose i logged the flow of my code and the flow of code is good and it even fetched the miles i wanted, except the error. What possibley could be going wrong? Could somebody help me?

@strXML nvarchar(3000),
@blnSkipMilesCalcByZip bit,
@bLogProcessFlow bit,
@calledFrom nvarchar(3),
@distance nvarchar(15)OUTPUT
AS EXTERNAL NAME CalculateMilesPCM.[CalculateMilesPCM.clsMiles].CalcMilesGetcitystate

DECLARE @distance nvarchar(15)
declare @testval nvarchar(15)
 EXEC usp_GetCalcMilesTest '<int_Loads BtLoadid="508952996" SHID="2480" Routetype="HB" SkipMil

WSE Security: Protect Your Web Services Through The Extensible Policy Framework In WSE 3.0


This article describes the WSE policy framework, which allows you to describe constraints and requirements a Web service must enforce. Discussions include security scenarios in WSE 3.0 and extending the framework with custom constraints and requirements.

Tomasz Janczuk

MSDN Magazine February 2006

Garbage Collection-Part 2: Automatic Memory Management in the Microsoft .NET Framework


The first part of this two-part article explained how the garbage collection algorithm works, how resources can clean up properly when the garbage collector decides to free a resource's memory, and how to force an object to clean up when it is freed. The conclusion of this series explains strong and weak object references that help to manage memory for large objects, as well as object generations and how they improve performance. In addition, the use of methods and properties for controlling garbage collection, resources for monitoring collection performance, and garbage collection for multithreaded applications are covered.

Jeffrey Richter

MSDN Magazine December 2000

Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework


Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory. However, you'll want to understand how it works. Part 1 of this two-part article on .NET garbage collection explains how resources are allocated and managed, then gives a detailed step-by-step description of how the garbage collection algorithm works. Also discussed are the way resources can clean up properly when the garbage collector decides to free a resource's memory and how to force an object to clean up when it is freed.

Jeffrey Richter

MSDN Magazine November 2000

Insufficient Memory to continue the execution of the program (Microsoft Visual Studio)


Since Upgrading to SSAS 2008, cannot explore Data or Browse cubes from Vista Untimate machine.

I am developing Cubes for Analysis and Data Mining in Microsoft Visual Studio. I am running Vista 64 Untimate on my PC with quad processors and 8G of memory.
Everything was working in SQL Server 2005 and Visual Studio 2005. When we upgraded to 2008 on the server, I can no longer browse the cubes that I create or explore the data in the tables that I am using. I get an insufficient memory to continue program execution message. I did some searching on the internet, and I think that it has something to do with how 2008 server and Vista use forms.
I have found the following detail on the load:

Insufficient memory to continue the execution of the program. (Microsoft Visual Studio)
Program Location:
   at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
   at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
   at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
   at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
   at System.Windows.Forms.AxHost.CreateInstance()<

how can i decrease memory usage by entity framework


i made one CMS on .NET4 And Entity Framework. this CMS in now begin used on server with shared memory.

application pool has limited memory so app pool reset when my application reach the memory limit . after trace my app i realize EF use most of memory . is there any way to decrease memory usage of EF or any tweaking?

my sample use of EF :

using BICT.Data;
public static List<Data.Log> GetList()
    using(CMSEntities cms = new CMSEntities())
       return cms.Log.ToList<Data.Log>();

am i use a wrong way to use EF?

How are targeted versions affected in new Framework Support Lifecycle Policy Change starting April 2


Hopefully this is the right forum, I searched and wasn't really sure where to put this.

In about a month the Support Lifecycle changes for the .NET Framework as referenced here http://support.microsoft.com/gp/lifeandotnet

We are trying to determine if we need to upgrade our applications or not and have gotten quite confused.

We have a number of web applications that target the 2.0 framework.  We also have Framework 3.5 SP1 installed on our web server.  3.5 SP1 uses the same CLR version 2.0 as Framework 2.0.  Because we have 3.5 SP1 installed, does that mean our applications that target 2.0 will still be covered under the new support lifecycle? 

Would the same apply to a web application that targets 3.5 that references a class library DLL that targets 2.0?

Thank You.

Memory leak in .net framework


Hi All,

is it possible to have memory leak in .net framework.If we are using any unmanaged code then there is a possibility, but what if our application is complete a managed application.Is there any chances of memory leak in case of managed code and if "there is a chances" then Can you please explain me how is that possible.Thanks for any help

"A .NET Framework error occurred during execution of user-defined routine or aggregate" followed by


I have some check constraints that call CLR functions.  Functions like 'CheckMailingAddress' and 'CheckPassword' just accept an nvarchar(4000) parameter, run the parameter through a Regex, and return true if it matchs and false if it doesn't.

Some of my functions are working fine.  They used to all work fine, and nothing has really changed, except all my database fields are nvarchar instead of varchar now (I added Unicode support).

I cannot see any reason why the CheckMailingAddress function fails, but the other functions succeed.  When I run CheckMailingAddress in a standalone app, it works just fine.  When it runs inside SQL Server, I get the message 'A .NET Framework error occurred during execution of user-defined routine or aggregate: "CheckMailingAddress": .', and as you can see there is no error message.  Just a space where there should be one, followed by a period.  I cannot explain this.

Compiling in Visual Studio 2010 and running on SQL Server 2008.


I noticed that it's only failing on functions that were built to accept null values (in the case where "allow_null" is true in the code below).  The check functions are auto-generated from custom attributes on the class in the C# code, and the MSIL is slightly different if the attribute indicates that the database

Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I'm sitting 30,000+ feet over the Atlantic ocean, I don't have access to VS2008 at the moment to check.

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.

Entity Framework 4 Tips for WinForms Development

I've been recently working on a smart client (WinForms) application backed by Entitiy Framework 4 (EF4) on Visual Studio 2010. In this blog post I will try to give you some tips regarding some limitations and points to be careful about EF4.

Bar Code Scanners with the .NET Compact Framework

Summary: Learn how to make your applications use bar code scanners in a generic way-ndependent of the specific bar code scanners that are used on different devices. Using the design patterns Façade and Factory, the implementation not only supports multiple bar code scanners, but it also makes it easy to add support for other bar code scanners. After a brief discussion about bar code scanners and the bar code scanner pattern, a download code sample, written in C#, demonstrates the use of the pattern and technologies.

Serial Communication with the .NET Compact Framework

Learn how to make your applications communicate over a serial port and how to handle common issues when implementing serial solutions. After a general discussion about serial communication and a common serial communication standard, this article demonstrates a practical use of the technologies through sample source code written in C#.
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