What can cause an OutOfMemoryException when calling Assembly.GetType?

Viewed 146

I'm developing a .NET MVC application and have recently introduced a new library via nuget. The application on load now throws an OutOfMemoryException.

The error points to a line of the web.config where we define the sessionstate provider:

<add name="MongoDBSessionStateProvider" type="UserDefinedType" description="MongoDB Session State Store provider" />

Of note is that the UserDefinedType is just the class name, it is not the assembly qualified class name.

I have determined that the problem seems to be that without the specification of which assembly it will just look in all assemblies and that when it looks in the assembly of this new library is when the out of memory exception is thrown. I have narrowed it down to reproducing in these two lines:

var assembly = Assembly.LoadFile(@"C:\MyProject\packages\NReco.PdfRenderer.1.2.2\lib\net20\NReco.PdfRenderer.dll");
var type = assembly.GetType("UserDefinedType", false, true);

I have further noted that if the last parameter (ignoreCase) is set to false then the error no longer occurs.

While I can fix the symptoms of this problem in my particular case by more fully specifying the class that is used for the session provider I have concerns about whether the underlying cause of this may cause other problems in the future so I am nervous about using this in production code.

So could anybody explain to me what causes this OutOfMemoryException?

0 Answers
Related