none
VB6.0 developed ocx used by VB.NET2005 applicaiton issues RRS feed

  • Question

  • I have a VB.net application developed in VS2005 that references an OCX file developed in VB6.

    The OCX file interfaces with a scanner over RS232 which allows for uploading and downloading configuration settings from and to a scanner.

    When my VB.NET app runs all is fine, the ocx member functions I call out execute successfully and I am able to communicate with the scanner(uploading and downloading),  however when I close my application, I get the following error:

    The instruction at "0xAddress" referenced at "0xAddress". The memory could not be read. Click ok to terminate program.

    If I run the application in Debug mode I get:
    LoaderLock was detected
    Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    I have tried disposing the object instance when the app closes but no such luck.

    I came across possible solutions on the web but none seem to work or Im not implementing it correctly. For example, I tried to debug it by tracing the call stack when the exception is thrown but Im not getting any info from the call stack.

    I am almost  certain this is an active X interop issue because the said .NET application at one time was developed under VB6 and the error did not occur.

    Any suggestions?

    Thanks
    Saturday, October 24, 2009 6:39 PM

Answers

  • Hi,

    I suggest you either;

    1. Switch to Pos .Net instead of the OCX (for dealing with the scanner), if you can, or;

    2. Repost your question in the VB .Net General or .Net Common Language Runtime forum. The issue not only doesn't relate to Pos .Net, which is specifically what this forum is for, but it sounds like a COM interop issue, or possibly a problem within the OCX itself... neither of which are problems likely to be answered in this forum I(even though a scanner is involved).

    Good luck, I hope someone in those forums can help !
    Friday, October 23, 2009 7:43 PM

All replies

  • I have a VB.net application developed in VS2005 that references an OCX file developed in VB6.

    The OCX file interfaces with a scanner over RS232 which allows for uploading and downloading configuration settings from and  to a scanner.

    When my VB.NET app runs all is fine, the ocx member functions I call out execute successfully and I am able to communicate with the scanner(uploading and downloading),  however when I close my application, I get the following error:

    The instruction at "0xAddress" referenced at "0xAddress". The memory could not be read. Click ok to terminate program.

    If I run the application in Debug mode I get:
    LoaderLock was detected
    Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    I have tried disposing the object instance when the app closes but no such luck.

    I came across possible solutions on the web but none seem to work. For example, I tried to debug it by tracing the call stack when the exception is thrown but Im not getting any info from the call stack.

    What else can I do?

    Thanks
    Friday, October 23, 2009 5:15 PM
  • Hi,

    I suggest you either;

    1. Switch to Pos .Net instead of the OCX (for dealing with the scanner), if you can, or;

    2. Repost your question in the VB .Net General or .Net Common Language Runtime forum. The issue not only doesn't relate to Pos .Net, which is specifically what this forum is for, but it sounds like a COM interop issue, or possibly a problem within the OCX itself... neither of which are problems likely to be answered in this forum I(even though a scanner is involved).

    Good luck, I hope someone in those forums can help !
    Friday, October 23, 2009 7:43 PM
  • I'll try to go with the second option and seek help on the other forums.
    I'm pretty sure it's an interop issue because the .NET app at one time was developed under VB6 and it worked fine with the ocx.
    Thanks for your reply!
    Saturday, October 24, 2009 2:40 PM
  • Memory management bugz in unmanaged code can go undetected for a long time, nothing like heap corruption to produce a Heisenbug.  Subtle changes in the runtime environment can be the trigger to make them heis.  There's nothing very subtle about the environment changes when you run inside a managed process instead of VB6.  Good luck with it, you'll need it.

    Hans Passant.
    Sunday, October 25, 2009 3:55 PM
    Moderator