Reputation: 97
I have already found this: Get Exception type from an exception
The given answer is exactly what I had in my code, but the type "SAP.Middleware.Connector.RfcCommunicationException" is not defined in my SAPConnector as it seems.
The relevant piece of code looks like this:
Public Sub RFC_Connect()
Dim rfcFunctionStandort As IRfcFunction
Try
'Build RFC-Connection
RfcDestinationManager.RegisterDestinationConfiguration(New SAP_Connect)
rfcDestination = RfcDestinationManager.GetDestination("SomeDestination")
Catch ex As SAP.Middleware.Connector.RfcCommunicationException
'Connection Refused
'Set the app to Offline-Mode
Catch ex As Exception
frmHauptmenue.txtEdit.ErrorLog(ex.Message)
End Try
End Sub
When running this without the first catch-statement it throws the "RfcCommunicationException" stated above.
Public Sub RFC_Connect()
Dim rfcFunctionStandort As IRfcFunction
Try
'Build RFC-Connection
RfcDestinationManager.RegisterDestinationConfiguration(New SAP_Connect)
rfcDestination = RfcDestinationManager.GetDestination("SomeDestination")
Catch ex As Exception
frmHauptmenue.txtEdit.ErrorLog(ex.Message)
End Try
End Sub
The import of the connector itself is done and working:
Imports SAP.Middleware.Connector
Upvotes: 0
Views: 4973
Reputation: 16595
The SAP NCo3 consists of two DLLs: sapnco.dll and sapnco_utils.dll. Did you perhaps reference only one of these in your Visual Studio project? In my project I have no problem using the RfcCommunicationException!
In fact: Visual Studio shows that RfcCommunicationException is exported from the sapnco_utils assembly. That gives me another idea: sapnco.dll is basically platform-independent, but sapnco_utils.dll contains unmanaged C/C++ modules and therefore needs to be used in a platform-dependent way (either 32bit/x86 or 64bit/x64)! So two other possible causes of your problem might be:
Upvotes: 1