Showing posts with label Exceptions. Show all posts
Showing posts with label Exceptions. Show all posts

Monday, October 17, 2011

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property


Fix JSON serialization error by setting maxJsonLength.

This error is occured when serialize an object in JSON string by JavaScriptSerializer class, it will throw this exception if object contains too many records(data). We can fix this issue by setting maxJsonLength in web.config file.
Exception type: InvalidOperationException
Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.


<configuration>
     <system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="50000000"/>
            </webServices>
        </scripting>
    </system.web.extensions>
 </configuration> .

Thursday, July 7, 2011

TargetInvocationException was unhandled by user code - Solution

I had been working with an Asp.Net Dynamic Data Web Application, I got an error while debugging the application.

TargetInvocationException was unhandled by user code : Exception has been thrown by the target of an invocation.



This error was because of the wrong filename in the entity connection string. I have fixed this and got it working.

If connection string is not exist in web.config, we will get the same error while debugging.

Note : always check the inner exception details when you are facing this error. This will help you to track out the actual exception caused the error.