vb.net com interop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Korry
    New Member
    • Aug 2008
    • 2

    #1

    vb.net com interop

    Hi
    I have developed some software using vb.net 2002 Version 7.0.9466
    The software accesses a 3rd party dll so I have had to use
    tlbimp.exe/com-interop etc.. to access it.
    When I use the software on my computer it will work fine,but
    it keeps having these intermittent crashes(just hangs),
    which involves restarting the program.
    The crashes, always occur when it accesses the 3rd party dll.

    I have installed the software on 2 desktop PC's and it works fine.
    On one PC I ran the software for 5 days and not a single hang.

    My laptop is a Dell M90 and has had a new motherboard and video card
    installed. This did not fix the problem. Recently I have also
    had a new hard disk installed (so a rebuild) but this hasnt fixed the
    problem either.
    I have also tried it in safe mode(XP Professional) but the hangs
    still occur


    Example of the Vb.net code to access the DLL
    'Define the dLL object
    Dim oMFWSB As New MOSSSystemBuild .MFWSystemBuild ()

    ' Access the dll
    Dim iErrRet as Integer 'Error/Success value
    Dim strMxModel as String ="Opt01"
    Dim strMxMask as String ="X"
    Dim StrMxStr as String 'String returned from following command
    iRet = oMFWSB.MFWGetSt rings(strMxMode l, strMxMask, strMxStr)

    'Release the dll
    Marshal.Release ComObject(oMFWS B)
    GC.Collect() : GC.WaitForPendi ngFinalizers()
    oMFWSB=nothing

    Any new ideas !!
  • vekipeki
    Recognized Expert New Member
    • Nov 2007
    • 229

    #2
    You should first try to identify the exact point at which your program hangs. If there is no exception thrown, try adding something like this, and then try to crash it:

    Code:
            
    Try
           Trace.WriteLine("Checkpoint 1 - before calling")
           ' call your COM method here
           Trace.WriteLine("Checkpoint 1 - after calling")
    Catch ex As Exception
           Trace.WriteLine("Exception while accessing COM object")
           Trace.WriteLine(ex.Message)
           Trace.WriteLine(ex.StackTrace)
    End Try
    Also add this somewhere during init, to direct Trace output to a log file:

    Code:
    Trace.Listeners.Add(New TextWriterTraceListener("MyLogFile.log"))
    It may be possible that the problem is not caused by the COM object, so try to locate the line where is happens first, by adding several Trace.WriteLine () "checkpoint s".

    Comment

    • Korry
      New Member
      • Aug 2008
      • 2

      #3
      I tried your suggestion but the try/catch/End try did not catch the error, as it was hanging on the Com call.
      I wonder if it is a system interrupt call as at times I can get it to crash when trying to open another application (such as Ultraedit or Internet Explorer)while the program is running.

      Cheers

      Comment

      Working...