2

This error occurred in asp.net & C# program:

System.Data.SqlClient.SqlConnection' in Assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable

what is the reason for this type of error occurred?

2
  • Tim Schmelter sir,Where i put my code ?.. Commented Aug 29, 2014 at 7:25
  • Edit your question and include the relevant code where you use that connection. Commented Aug 29, 2014 at 7:26

1 Answer 1

3

Because you are trying to put SqlConnection in either a viewstate variable or you are trying to serialize the SqlConnection. The SqlConnection is not serializable that is why the error accrue. If it would be a class that you define yourself. Then you can mark it as serializable and then the error will not accoure. Like this:

[Serializable()]
public class YourClass
{
}

Reference:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.