C# DllImport Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tk121
    New Member
    • Mar 2008
    • 6

    C# DllImport Problem

    Hello -

    I have some code I'm invoking with DllImport and the functions work flawlessly while executing through the debugger, but not in the stand-alone executable. When running the exe, the program hangs as soon as it gets to executing the dll. After awhile it will say "(Not Reponding)".

    The code also works on console applications, both in the debugger and the built executable.

    So, what's the difference between the console app and the windows app (and the debugger) that could be causing only the windows app to hang while running my dll, when it works fine every other time?

    Thanks in advance for any help!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Are you making references to any pointers or GUI components in these dll functions?

    Comment

    • tk121
      New Member
      • Mar 2008
      • 6

      #3
      Originally posted by Plater
      Are you making references to any pointers or GUI components in these dll functions?
      No - In fact some of the external functions that I'm testing with don't have any inputs at all.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Are you using the results in GUI objects anywhere?
        In your windows form application, start adding like logging statements after like every line in your code and have it log to a file (or something)
        Then run your code and see how far it gets.

        If you can, maybe even do the same in the DLL you are using.

        Comment

        • tk121
          New Member
          • Mar 2008
          • 6

          #5
          Originally posted by Plater
          Are you using the results in GUI objects anywhere?
          In your windows form application, start adding like logging statements after like every line in your code and have it log to a file (or something)
          Then run your code and see how far it gets.

          If you can, maybe even do the same in the DLL you are using.
          I added logging statements and it gets right up to the point where it calls the external function, and then hangs right on that call. The first statement in the dll function (a simple printf statement) never executes.

          If I didn't know better, I'd think it was having a problem finding the dll, or the insertion point for the function, but everything works like a charm in the debugger (and on a console app), so I don't think it's that.

          When running through the debugger it executes the embedded printf statement as well as logging statements after the dll function exits.

          Comment

          Working...