Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SapServer Error Event Handler - unable to use #98

Closed
tom-j-irvine opened this issue Jun 26, 2024 · 4 comments
Closed

SapServer Error Event Handler - unable to use #98

tom-j-irvine opened this issue Jun 26, 2024 · 4 comments

Comments

@tom-j-irvine
Copy link

I have been successfully using the SapServer functionality for quite a while, but haven't been able to handle errors in the connection. I'm handling the StateChange event which works as expected when the server is explicitly started, stopped, etc. However, if something breaks the connection on the SAP side (including forcing the disconnection in SMGW), the StateChange event doesn't fire. It does appear this is correct, but any attempt to handle the Error event immediately aborts my application.

I can add the Error handler at startup without issue. However, as soon as it fires, my application crashes and I'm unable to trap the exception. The exception looks something like this:

An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module.: 'Object reference not set to an instance of an object.'
Stack trace:
 ><Cannot evaluate the exception stack trace>

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

In the debugger, the offending thread shows Thread - [Managed to Native Transition]

So, it would seem this issue is off in un-managed code that I can't handle myself. I looked pretty closely at the RFC SDK documentation vs. the RfcInterop and I don't see any discrepancies.

These are the steps I can use to cause the issue:

  • Start up RFC server and register a handler for the Error event
  • In SAPGUI, in transaction SMGW, Goto -> Logged on Clients
  • Select the connection and Goto -> Logged on Clients -> Delete Client

Any input or help on how this event can be handled would be greatly appreciated.

@campersau
Copy link
Contributor

Are you using this implementation 7fa7175 ?

@tom-j-irvine
Copy link
Author

No, that doesn't look exactly like what I have. I can try adding those changes see if it changes things.

@campersau
Copy link
Contributor

I added that later in #53

@tom-j-irvine
Copy link
Author

That is what I needed. Error event is working now and will be very helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants