Problem uploading large files in ASP.NET

12. October 2012 10:35 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

If you try to upload large files you might get an exception like

HttpException: Maximum request lenght exceeded.

This problem occurs because the default value for the maxRequestLength parameter in the section 

of the machine.config or Web.config file is 4096 (4M).

So any file with a size bigger will fail.

However I think that the max size that you can write here is 2G 2097151

Some info can be found here:;EN-US;295626


So to change that for 512mb use something like:




        <httpRuntime maxRequestLength="524288" /> 



IE8 No such interface

17. August 2012 10:45 by Mrojas in   //  Tags: , , , , , ,   //   Comments (0)

Well, there are several reasons why this error appears...

I had this annoying error for a few days so I decided to track it down. It seems that in my case this error was a bug in jQuery.

if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                    return a !== b && (a.contains ? a.contains(b) : true);



That code throws the exception in the a.contains(b) method call. So I tried to fix it for a while but I did not have a lot of time so I ended up patching it like:


if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                try {
                    return a !== b && (a.contains ? a.contains(b) : true);
                catch (err) {
                     return false;

In my case it works. I know is not the best solution but if you are struggling with this it might help

Using MARS or There is already an open DataReader associated with this Command which must be closed first.

14. December 2011 10:11 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)


This is a very strange error that you can find sometimes when working with ADO.NET.

David McKean from MSFT says:

This occurs when you have multiple DataReaders open concurrently on the same connection,
ie you call SqlCommand.ExecuteReader but don't close the SqlDataReader returned by this
method before calling it again (either on the same command or another command on the same connection).

It requires a feature called MultipleActiveResultSets which is not available in all providers.

For example SQL2000 does not support it, it was implemented starting from SQL2005.

Also .NET 2.0 must be used.

For more information about enabling Multiple Active Result Sets see:

A good recommendation to make sure that the the readers are closed is to put them inside a using statement, in that case,
no matter if an exception happened they will be closed and disposed.

If you are using SQL Server 2000, MARS is not available so you can create two different connection objects.

Another good article about this issue is:


But in general to use it is just a change in the connection string:

    <clear />
      <add name="VasquezDB" 
         connectionString="Data Source=rvasquez;Initial Catalog=VasquezDB;
                 Integrated Security=True;MultipleActiveResultSets=Yes" />


Good Luck


NOTE: a good link with more details about MARS is:

Return argument has an invalid type

10. December 2009 07:39 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

When you develop applications with remoting, or in some COM + Remoting scenarios, you could start founding very interesting exceptions.

We had a very unconfortable one. We had an ActiveX that is used in an intranet Web Page, that uses remoting to instanciate some classes in the local network.

When we runned outside of the IE, everything seem to work, but running in IE it produced an exception like:

Error : Return argument has an invalid type.
Type  : System.InvalidCastException
Source: mscorlib
Source: at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

Why??? Well what happens is simple, it is having an assembly resolution problem, it is not being able to resolve the type.

We solve the problem adding something like:

1. Find a place in your code to add an event like this (it could be in the Main of your program for example):

AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
2. Add a handler like this: 

static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
System.Reflection.Assembly assembly = null; 
assembly = System.Reflection.Assembly.Load(new System.Reflection.AssemblyName(args.Name));
   catch (Exception ex)
            string.Format(“Problem with resolution of {0} : {1} {2}”, args.Name, ex.Message, ex.StackTrace));
   return assembly;

Well, this worked for us, and I hope that helps you out.