I have a COM component written in VB6 that I'm using from a Visual Basic .NET application through COM interop.
There is a method that throws an OutOfMemoryException when called from VB.NET. However, when I run the exact same call from a Visual Basic 6 application, everything works fine.
I cannot post code here because it is too long and hard to follow (I'm tasked with fixing it) and I can't pinpoint the problem, because when I try to debug it from VB6, the error doesn't show up.
What could be causing this distinct behavior?
This was working fine until I fixed a performance problem using a Dictionary object (a COM one from the Microsoft Scripting Runtime). Unless the Dictionary is growing irrationally or leaking, I don't see how it could be causing this, since it never grows past 100-200 elements and only one is created before the exception is thrown.
I tried the same fix with a Collection object and an awkward Exists() function and the same problem happens. If I bail out early by returning Nothing, it works (i.e., it throws NullReferenceException, as would be expected).