开发者

Issues with COM Interop and .NET 3.5 - different behaviors in Debug and Release mode

开发者 https://www.devze.com 2023-01-31 11:33 出处:网络
We have been troubleshooting the following and are looking for some fresh ideas or angles of attack. First scenario:

We have been troubleshooting the following and are looking for some fresh ideas or angles of attack.

First scenario:

We have an ASP.NET web application - .NET 3.5, C#, built targeting x86 - running on IIS7/Windows Server 2008 R2 (64 bit). The ASP.NET web application runs under the default application pool with 32 bit applications enabled.

This web application leverages some legacy components written in VB6 and built as ActiveX DLLs. The DLLs are registered using regsvr32. References to these components are added to the web application project (Visual Studio 2008) and we're using the generated Interop classes.

When the web application is built in Release mode, errors are thrown by the legacy code fairly deep in the subroutine stack every time a call is made to those legacy VB6 components. It's usually something like:

ERROR 91 Object variable or With block variable not set [ComponentName:ClassName.cls:MethodName]

When the same web application code is built in Debug mode instead, the same errors occur but they are intermittent. If the same action is repeated in the web applicati开发者_Python百科on 10 times (same inputs, everything else being equal) we'll see the problem approximately once.

Second scenario:

In addition to the web application, we have a .NET 3.5 C# application built targeting x86 that runs as a Windows service on Windows Server 2008 R2 (64 bit). This service makes calls to an ActiveX EXE that is related to the DLLs used by the website (common legacy heritage and dependencies). The ActiveX EXE is registered using the /regserver switch and a reference added to the .NET project. The generated Interop classes are used. As is the nature of ActiveX EXEs, method calls execute asynchronously in their own thread and use events to notify the caller of completion.

If the .NET application is built in Release mode, method calls to the EXE do not raise errors (as far as I can see), but the event that should be raised in the ActiveX EXE to indicate success is not received by the .NET application.

If the same .NET application code is built in Debug mode, the event is raised by the EXE and received/handled by the .NET application.

I've posting these issues together because they both change with debug versus release build and my hunch is that the causes are related. Currently we're focusing on potential issues with garbage collection and the out-of-process work done by the ActiveX EXE and threading issues in the web application. Any ideas about areas we should investigate would be welcome.


Try this: BUG: "Object variable or With block variable not set" on ms support

0

精彩评论

暂无评论...
验证码 换一张
取 消