I am connecting SAP system with .NET 4.0 using connector.... I have created a sample windows appln to check whether it's connecting or not.. This is my code...

    private void Form1_Load(object sender, EventArgs e)

            SAPSystemConnect sapCfg = new SAPSystemConnect();
            RfcDestination rfcDest = null;
            rfcDest = RfcDestinationManager.GetDestination("Dev");

        catch (Exception ex)

           // MessageBox.Show("ERROR");



Nothing happens when I run this code... Even if i give wrong user name and password in app settings(config file), it's not showing any exception, it's just loading the form...

Can anyone clear my doubt? Do we have any other way to find whether the system is connected?

Was it helpful?


SAP Net Connector uses a connection pool. So you usually don't connect or disconnect yourself, the NCo library does that for you. As soon as you actually need a connection it will be established. To simply test your code you could for instance try creating an IRfcFunction instance:

rfcDest = RfcDestinationManager.GetDestination("Dev");
IRfcFunction fnc = rfcDest.Repository.CreateFunction("RFCPING");

that should trigger the connection. But in general you don't need to open the connection before communicating with the SAP system, you just need to be prepared for the possibility that the connection can't be established (wrong parameters, system is down etc.).


One thing you can do is Unregister the configuration after work is done by using


and next time when you try to connect register it again and use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top