Callback from DLL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nenad Dobrilovic

    Callback from DLL

    Hi,

    I have one annoying problem. I made callback function from DLL made in
    C++ to C# program. As I can see, it is rather easy, and there was no
    reported problems on Internet.
    But, it doesn't work in my code...
    It should work like this: I call 'Connect' function in DLL, which starts
    the thread; the thread calls (using callback) functions in managed code.
    When I walk through debbuger, and I stop the main thread in C#, it
    really works for one or two times, but after that I get "privileged
    instruction" exception. I opposite case, when main thread is not
    stopped, I get exception immediately.
    If I don't use debugger, it doesn't work at all. I get "null reference"
    exception first time when callback should be called.

    Can anyone help me?
    Thank you in advance, Nenad
  • Nenad Dobrilovic

    #2
    Re: Callback from DLL

    Nenad Dobrilovic wrote:[color=blue]
    > Hi,
    >
    > I have one annoying problem. I made callback function from DLL made in
    > C++ to C# program. As I can see, it is rather easy, and there was no
    > reported problems on Internet.
    > But, it doesn't work in my code...
    > It should work like this: I call 'Connect' function in DLL, which starts
    > the thread; the thread calls (using callback) functions in managed code.
    > When I walk through debbuger, and I stop the main thread in C#, it
    > really works for one or two times, but after that I get "privileged
    > instruction" exception. I opposite case, when main thread is not
    > stopped, I get exception immediately.
    > If I don't use debugger, it doesn't work at all. I get "null reference"
    > exception first time when callback should be called.
    >
    > Can anyone help me?
    > Thank you in advance, Nenad[/color]

    Problem is solved by moving the code for registering delegates to DLL
    from main thread to working thread.

    Nenad

    Comment

    Working...