. Net Framework Data Provider Error

Source: Internet
Author: User
This exception occurs when the Dispose () method of the SqlConnection object is invoked in the destructor, but not elsewhere. Search for MSDN resources to find answers:
Http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=473449&SiteID=1
The following is an explanation of the Sqldatareader.close () method:
Http://msdn2.microsoft.com/en-us/library/system.da ta.sqlclient.sqldatareader.close.aspx
Note this text:
Do don't call Close or Dispose on a Connection, a DataReader, or no other managed object into the Finalize method of your CLA Ss. In a finalizer, your should on -ly release unmanaged The Your class owns directly. If your class does not own the any unmanaged resources, does not include a Finalize method in your class definition.
Do not call connection, DataReader, or the close () or Dispose () methods of other managed objects in destructors, the destructor should simply place the unmanaged members of the class, and do not create destructors if the class does not contain unmanaged members.

This type of problem usually occurs when a thread-safe object is accessed across threads, and even if you do not show one, there will be separate threads within the CLR.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.