Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal Reports ActiveX Viewer causes Out of Memory exception in VB6 / .NET App Windows 7

Here is a link to a sample application which reproduces the error: http://sdrv.ms/17j2Ale

I have three projects. One is a .NET 2.0 Windows Forms application (.NET App), one is a VB6 Standard EXE application (VB App), and the other is a VB6 ActiveX DLL (VB DLL). The .NET App references the VB DLL which is already registered. This VB DLL essentially launches Crystal Reports. The VB App launches the .NET App via the Shell() command. Here's what happens:

If I run the .NET App directly, I can open a Crystal Reports document with no problem. However, when the VB App launches the .NET App via the Shell() command, when the .NET App attempts to open the Crystal Reports document, I get an Out of Memory error.

Now here's the kicker - this worked on Windows XP, but when we attempt to launch it in Windows 7 64-bit, we run into this issue. I'm sure there's got to be a simple solution out there for it. Any takers?

You can jump to Update 5 where I narrowed down the problem.

Update: I also tried creating a second .NET 2.0 Windows Forms application (.NET Launcher), and launched the .NET App from it via:

Process.Start(@"C:\Path\OtherApp.exe");

and when I tried open the Crystal Reports document in the .NET App it still gave me the same Out of Memory error.

Update 2: removed due to update 4

Update 3: So today I discovered that the reason the .NET App was able to open the report when it was launched directly was because I was launching it within Visual Studio. When I tried the executable outside Visual Studio, the error returns. I noticed that Visual Studio, as of 2005, began using a vshost.exe to launch windows applications to speed up debugging startup: http://blogs.msdn.com/b/dtemp/archive/2004/08/17/215764.aspx When I disabled the vshost feature, the out of memory error returned. So I suppose the question is, what is this vshost process doing that allows it to work on windows 7?

Update 4: I was able to compile the VB6 DLL with debug information and load the source and debug information into Visual Studio and step through it when the .NET app executes the VB6 code. The Out of Memory exception comes from this line:

Dim myForm As frmTheForm

Set myForm = New frmTheForm 'OOM Error right here

So inside the vshost.exe this form is able to initialize but not without it.

Update 5: I have narrowed down the problem to the Crystal Reports ActiveX Viewer. I started a new VB ActiveX DLL project from scratch and started with only a form. This worked every which way. Then I added the Crystal ActiveX Report Viewer Library 11.5 - and the error returned! It is definitely the Report Viewer. I'm told that this problem may be able to be fixed by a simple registry adjustment.

Update 6: I used Procmon.exe from Sysinternals and generated a logfile that can be found here:

http://sdrv.ms/194aO7A

like image 383
Zach Avatar asked Nov 03 '22 17:11

Zach


1 Answers

I've got such problems when I use 32Bit C/C++-Dll's with .NET code running on 64Bit Windows. If your .NET project has "any platform" as target then the runtime compiles the code to 64Bit on a 64Bit Windows, on a 32Bit Windows I think you'll have no problems.

You have to set your target platform to "x86", you wrote you did this. Please verify that all your .NET projects in your .NET solution are set to x86 as target.

The Crystal Reports *.dll should be a 32Bit COM *.dll, and the VB6 *.dll too.

like image 95
user743414 Avatar answered Nov 15 '22 06:11

user743414