cancel
Showing results for 
Search instead for 
Did you mean: 

Different exceptions when calling Repository.CreateFunction()

Former Member
0 Kudos

Good day all,

At the moment I am developing an application that needs to assure that a connection with SAP is maintained. This will be done using a simple RFC call. Since I am not able to have an actual connection to SAP at the moment I am not surprised by receiving an RfcCommunicationException when running the code below:

RfcDestination _rfcDestination;
    IRfcFunction _connectionTester;

    _rfcDestination = RfcDestinationManager.GetDestination(tbName.Text);
    try
    {
        _connectionTester = _rfcDestination.Repository.CreateFunction(tbConnectionTestMethod.Text);
    }
    catch (System.Exception exc)
    {
        _log.Error("Unable to create function.", exc);
        throw;
    }

I was surprised, however, that I received a System.ArgumentNullException on subsequent calls (without closing the application). If I restart the application I will first get the RfcCommunicationException followed by the System.ArgumentNullException.

Is this to be called normal behaviour or does this mean that once the connection is lost, the only way to get connected again is to restart the application?

Thank and regards,

Bjorn Wennemers

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I'm having a very similar problem. I'm using the connection code supplied with the nco 3.0 connector. On the initial call to

RfcRepository repository = destination.Repository;

An RfcLogonException is raised as expected. However, on subsequent calls, the expection ArgumentNullException is raised instead. I would certainly expect the RfcLogonException exception to be raised each time if thhe application was not able to make a connection regardless of whether it's the 1st or 10th attempt. Obviously, this has something to do with having an active connection. I've tried reducing the connection pool to 0 and messing with the time out setting to no avail. This seems to be a bug in the connector.

Former Member
0 Kudos

I'm having the same problem and can't figure out the reason.

Hope someone help us out.

Former Member
0 Kudos

You can try checking the connection state or use ping() method before trying to do the subsequent attempt.