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

Top 5 Contributors of the Month
Post New Web Links

SEHException in Finalyzer while disposing SoftHandles

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :.NET Framework


Hi All,

     I am hitting with SEHException while disposing Softhandles which are internal to .NET Framework. Can you please suggest me a way to how to solve this issue ? When i check the stack, almost all the softhandles are pointing to the same object, that surprises me more. Please do check the Windbg output :


!threads output


  0    1 2fd4 0015b790      a020 Enabled  00000000:00000000 00163f78     0 MTA
   2    2 3174 0016e5f0      b220 Enabled  00000000:00000000 00163f78     0 MTA (Finalizer) System.Runtime.InteropServices.SEHException (0c3e9468)
   3    5 4be8 00195d30      b220 Enabled  00000000:00000000 00163f78     0 MTA
   4    7 40ac 001b8798      b220 Enabled  00000000:00000000 00163f78     0 MTA
   6    9 4b50 001c6d08   200b220 Enabled  0000

View Complete Post

More Related Resource Links

disposing SPSite and SPWeb objects?

hi          can i code using(SPSite oSite=SPContext.Current.Site) {    using(SPWeb oWeb=oSite.OpenWeb()) {} } or should i code like this SPSite oSite=SPContext.Current.Site; using(SPWeb oWeb=oSite.Openweb()){} which is better? i am trying to code this inside ItemAdding Event handler. please suggest

Disposing a SqlConnection (ADO.NET)


Hello guys,

I had a question relating to the disposal of a SQL connection. I have some code that checks whether a certain database is present on a SQL Server instance. This code is being called in an installer, so what I actually want it to do is ensure that there isn't already a database on the server with the same name than the one that will be created in the installer. If such a database exists, the user will be notified so that he can remove the database manually, and then click OK or something to let the installer proceed. I extracted the relevant piece of code. This snippet can be used in a console application to reproduce the problem:

static void Main(string[] args)
 		string connectionString = "Data Source=.;Initial Catalog=MyDatabase;User Id=MyUser;Password=MyPassword;";

		using (SqlConnection connection = new SqlConnection(connectionString))


Disposing things


Hi Everybody,

I have noobishly written an ASP.Net without any Dispose methods for unmanged objects. The object I am using are Sqlconnection, Sqlcommand and SqlDataReader. My application on my shared host shows very high resource usage, and I'm the only one using it. Which seems to me like a badly designed app. Because it's done in C# ASP.Net 3.5 the garbage collection should handle managed objects without my intervention correct? But it doesn't handle unmanaged objects I think.

So I had a look at FxCop and ran it on my app. But it is coming up with no error for "Implements IDisposable correctly" in my whole app. This seems odd since I have not used the Dispose method once. So here is a section of my code for example. Is this code leaking memory? most of my code is the same with different params tables etc.

public List<Classy> Get_Classy(int classyId)
        List<Classy> classyList = new List<Classy>();
        using (SqlConnection connection = new SqlConnection(connStr))
            SqlCommand command = new SqlCommand();
            command.CommandText = "SELECT * FROM ClassyStore WHERE classyId = @classyId";
            command.CommandType = CommandType.Text;
            command.Connection = connection;

Disposing when hower AND CTRL is activated AND left mouse button is pressed ????


I want to let the user get rid of some designelements (PictureBoxes) on a form very fast.

This code can do it IF the user holds down the CTRL-key AND moves the mouse cursor over the designelements.

    private void signal_MouseHover(object sender, EventArgs e)
      Cursor.Current = Cursors.Hand;
      if (commonThings.ctrlActivated)

I have two problems witch I can't solve:

1) I want to secure wrong deleting of designelements by ALSO test that the LEFT-mouse key is pressed togather with CTRL (there is no "buttons" with the e !)

2) the Hover-event is a little delayed, so the deleting is in fact a little slow

How can this be done ?


Best regards KSor, Denmark

disposing a Modelvisual (reset viewport and load new model)



I am constructing a 3D model viewer, and all is working quite well at a first glance. But when i want to load a new model the memory will not reset so after two or three "new loads" the program process breaks the 2Gb limit and exits. I have used "perfmon" to monitor the private bytes used by my program and I can see that almost no memory is returned between loads (with one exception, I'll return to that in a sec)

in my model class i have variables such as:

  • GeometryModel3D
  • MeshGeometry3D
  • ModelVisual3D
  • Bitmap
  • DiffuseMaterial
  • List<string>
  • Int32Collection
  • Point3DCollection
  • PointCollection

And when trying to create a new model I first remove the current model with the following:


 ModelVisual3D m;

 i = myViewport.Children.Count - 1; i >= 0; i--)
 m = (ModelVisual3D)myViewport.Children[i]; 

 (m.Content is
 DirectionalLight == false


as seen at http://ww

Disposing a Dataset in vb.net


Hi Guys,

I want to Dispose  dataset in vb.net to release memory at run time

I just use the given below code & dataset is still available to me....

Dim dsSomeData as Dataset
dsSomeData = objSomeObject.GetSomeData()
dgDataGrid.DataSource = dsSomeData

so it that mean dispose() method is just fake method and the Dispose method in DataSet exists ONLY because of side effect of inheritance

Pls advise.



Disposing of objects



Can someone answer me how the GC will dispose objects created in the following 2 scenarios:


Private Function DoSomething() As Boolean
	Return New DatabaseManager().Insert()
End Function


Private Function DoSomething() As Boolean
	Dim mngr As New DatabaseManager()
	Return mngr.Insert()
End Function

As you can see, in the option 1, i dont create local variable to hold the reference of the object. In the second option, i hold the reference in local variable.

What option is better and why? (if any)





Disposing DbConnection variable of an object used as a local instance



I have a class with a property of type DbConnection.
That class is instanciate inside a method as a local variable.
Do I need to dispose the DbConnection property value when disposing the entire object?


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