Our software is written in C# and needs to connect to SAP. As some of our customers use older versions of SAP, and others don't have SAP PI, we can't connect through webservices.
I tried to connect to SAP through the SAP NetWeaver Remote Function Call Library (sapnwrfc.dll) as follows:
- Add sapnwrfc.dll and the other dlls from NWRFC_6-20004550.SAR (being icudt34.dll, icuin34.dll, icuuc34.dll, libicudecnumber.dll, and libsapucum.dll) to C:\WINDOWS\system32, to be sure that they can be found.
- In my C# code add the following in the class definition:
[DllImport("sapnwrfc.dll", CharSet = CharSet.Auto)]
public static extern void RfcInit();
and the following in the method that should do the work:
RfcInit();
Running this code gives a DllNotFoundException:
Unable to load DLL 'sapnwrfc.dll': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
Running the standard connect-to-C++-from-C# example
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
works fine.
Any suggestions how to make this work fine (so that we don't need to workaround this problem by writing a Java proxy using JCo)?